Article Options
Recently Viewed
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Simple Steps in VB.NET. Part 3 - Address Book 2
Simple Steps in VB.NET. Part 3 - Address Book 2
by George Poth | Published  06/05/2003 | .NET Newbie | Rating:
George Poth

I have been teaching English in Brazil since 1994 and always wanted to do more for learners than common textbooks can offer. This started with web sites that couldn't reach most students as computers and the Internet are not standard for most people in this country.

Computer tools to help Brazilian students learn a complex language like English are practically non-existent and so I sent some suggestions to software companies. Since Brazil is neither a target market for English textbooks nor for software of this kind, the rejection seemed natural.

As a result, I tried some free developer tools such as Borland's free C++ compiler, Free Pascal, and Envelope's Visual Basic. Envelope's Visual Basic, which is a Microsoft Visual Basic 1.0 clone and still available, suited my taste but I knew it was obsolete technology. In March 2003, I bought a copy of Microsoft Visual Basic .NET Standard and have been hopelessly contaminated with the programming virus ever since.

I mostly write programs for educational purposes. Having discovered the wonderful world of DirectX recently, I am diving into the most entertaining part of programming: games. One can connect teaching with pure entertainment, learning, and culture.

 

View all articles by George Poth...
Simple Steps in VB.NET. Part 3 - Address Book 2

Article source code: ssteps3_addressbook2.zip

The address book we started in Part 2 is already fully functional, but some things should be improved. Run the program and press the tab-key several times while observing the textboxes and the buttons. You will see that each time you press that key another textbox or button gets the focus. When a textbox is focused, a user can type into it without clicking it. When a button is focused, a user could simply press Enter to execute the action for which the button was made. Our tab-key works, but not quite as a user would expect it. That's why we are going to make some changes.

We have made the ID-textbox read-only. A user can't modify the content, so why would he/she go there using the tab-key? Think sharp! And if you ever get the answer, let me know. Since I can't think of a good reason, I will simply disable the tab-key for this item. To do so, go to the properties window and set the tab-stop property to false. The ID-textbox will be ignored from now on when you press the tab-key in the running program.

The tab-key should work with all other textboxes because the user is supposed to enter data. We have to rearrange the tab-indexes so that each time you press the tab-key, the next textbox gets the focus. You can change the tab-index number in the properties window, right above the tab-stop property. Change the numbers as shown in the table. Make sure you click each item before you try to change things.

Tab-Stop NumberItem
0editName
1editSurname
2editStreetAddress
3editZipCode
4editState
5editPhoneNumber
6editEmail

The tab-key also works with the buttons. For the sake of simplicity, disable the tab-key for all the buttons. It works the same way as you did with the ID-textbox. Don't think I'm sloppy. Many of you might think that setting the tab-key for the buttons is very simple, but believe me, it's not. They can be very useful when planned carefully. They can also easily become a pain in the - aw, I'm sure you know where - when you just put them there to show off. It would take more time to go into this, so let's have that in a later article. When you're done with the tab-indexes, run your program and see that it has improved a lot with these simple changes.

Speaking of changes, all programs have an icon, and ours? Yuh, okay, we have that blue-blah-blah standard application icon, and we have that primary-color-I-wish-you-weren't-there-anymore standard icon in the title bar. For those who like changes, I have included a different icon in the bin folder of the program. The icon comes from a web and lets us use it for non-commercial purposes. Sorry, but I won't advertise this web here because that's not my job.

To change the icon in the title bar, go to the properties window and find the property "Icon". Click the icon once so that the ellipsis appears. Then click the ellipsis and browse for your icon. Finally, click the icon. Wow, it's changed!

The application icon is the icon that would appear in the users menu if you installed the program on a computer. Changing the blue-blah-blah application icon is equally easy. In the Solution Explorer, right-click Addresses and choose Properties. In the Addresses Property Pages window, click Build in the left pane. You will see our old friend in the window, the blue-blah-blah application icon. Click the ellipsis on the left, next to the drop-down box which reads Default Icon. Browse for your icon as you did before and click it. You must build your program before you can see the change. When you have built it, open the folder of your program, the Debug folder, and see that the standard application icon has gone.

In Part 1 (The Button), we used tool tips, remember? Tool tips are those small yellow messages that pop up when the mouse goes over an item. Let's use them again. Just repeating what we've already learned would be dull, wouldn't it? How about multiple-line tool tips?

From the toolbox, insert tool tips. I hope you remember how that works. If you don't, feel free to review that part. It's not necessary to rename this item because we have only one. My habit is - I know, I have a lot of them - to rename everything to something very, very short, but it must remain easy to identify. I renamed my tool tips from ToolTip1 to msg. Why? I'm very, very lazy. I believe it's easier to type "msg" in each line than "ToolTip1".

Before you start writing your tool tips, you should change the property AutoPopDelay. Change the value from 5000 to 15000. This will display our tool tips for fifteen seconds instead of only five. You won't believe it: most programmers don't even bother to check this item although they have fifteen lines - or more - of tool tips. So after five seconds you're supposed to have read those fifteen lines. Ah, yes, and always check your text for spelling mistakes; they can make a horrible impression on some users.

Make sure you write each tool tip as one line. The code you see displayed here must fit the page, so it's impossible to reproduce it as it should actually look in your code. If you're in doubt, have a look at my updated sample. In part 1, I have intentionally not used multiple-line tool tips because these require more attention from you. It's very easy to get an error due to something as simple as an empty space. Observe these empty spaces when you write the code.

Private Sub DataForm1_Load(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles MyBase.Load

    'textbox tooltips:
    msg.SetToolTip(editID_
        "This number is generated automatically." & _
        Microsoft.VisualBasic.ControlChars.CrLf & "You can't change the " _
        & "input.")
    msg.SetToolTip(editName"Type the person's first and middle name here.")
    msg.SetToolTip(editSurname"Type the person's family name here.")
    msg.SetToolTip(editStreetAddress"Type the street address here.")
    msg.SetToolTip(editZipCode"Type the zip code here.")
    msg.SetToolTip(editState"Type the state here.")
    msg.SetToolTip(editPhoneNumber"Type the phone number here.")
    msg.SetToolTip(editEmail"Type the e-mail address here.")

    'button tooltips:
    msg.SetToolTip(btnLoad_
        "Click to load the database." & _
        Microsoft.VisualBasic.ControlChars.CrLf & "No changes can be made" _
        & Microsoft.VisualBasic.ControlChars.CrLf & "before the database " _
        & "is loaded.")
    msg.SetToolTip(btnAdd"Click here before you add data.")
    msg.SetToolTip(btnUpdate"Click here to update/save data.")
    msg.SetToolTip(btnCancel"Click here to reject the last changes.")
    msg.SetToolTip(btnCancelAll"Click here to reject all changes.")
    msg.SetToolTip(btnDelete"Click here to delete the visible entry.")
    msg.SetToolTip(btnClose"Click here to close the program.")
    msg.SetToolTip(btnNavFirst"Displays the first entry.")
    msg.SetToolTip(btnNavPrev"Displays the previous entry.")
    msg.SetToolTip(btnNavNext"Displays the next entry.")
    msg.SetToolTip(btnLast"Displays the last entry.")

End Sub

Each time you type & Microsoft.VisualBasic.ControlChars.Crlf &, you actually start a new line. This also works with message boxes, as we will see later today.

We still have Form1 which we are going to use to inform the user about you. The first thing we have to do is to display this form. Let's use a menu to do so. If you now thought of a menu from the restaurant, you certainly need a bit more imagination. In the toolbox, double-click the item MainMenu. The menu will appear in the upper left of the form with the text "Type Here". Click the text and type Help. Press Enter and type About. Click an empty space in the form to see your menu. Click the menu, then double-click About and edit the code so that it looks like this one:

Private Sub MenuItem2_Click(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles MenuItem2.Click
    '"about" is the descriptive name of our form.
    'Form1 is the object.
    Dim about As New Form1()
    about.Show()
End Sub

To see if we got it right, build and run the program and click the menu to open Form1 (About). When the form comes up, it should be clear that there are some things we should change. Close the program and make the necessary changes. To display Form1, double-click Form1 in the solution explorer. You should be consistent with your colors, so consider giving it the same color as your DataForm1. The appropriate title could be "About". You should also check the startup position and the icon.

There's no reason why someone would want to resize, minimize, or maximize this form, so let's change those properties, too. In the properties window, find the property FormBorderStyle. Change this property to FixedSingle. Your form can't be resized anymore with this choice. It's a good idea to try all properties so that you know what effect they will have. To see the effects, you have to build and run the program. Maybe you prefer to set a different property. Next, find the properties MinimizeBox and MaximizeBox and set their properties to false. Your form now can't be minimized or maximized anymore. If you prefer, do the same with DataForm1.

Insert a button into Form1 and rename it to btnClose. You could also change the text property to Close, but let's do that in a different way. Double-click the form and edit the code to the following:

Private Sub Form1_Load(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles MyBase.Load
    btnClose.Text = "Close"
End Sub

Now go back into design view. You will see that the text has not changed. Build and run the program, click the menu item About, and see what happens. Ah-hah! The correct text is displayed. You can change the text property for all items within the code. For example, if you have a label named Label1 and you want to change the text to "Hi, everybody!" you just write Label1.Text = "Hi, everybody!". The advantage is that it's much faster if you have lots of items. The disadvantage is that you can see the text only when you run the program. I personally prefer to set the text in the properties window so I can see it all the time. It's slow, but I have already messed up once in a very large program, so I'm more careful now.

Double-click the button and write the code so that it closes the form. Remember that I told you that many ways lead to Rome? I also told you that there can be differences in codes which apparently do the same thing. Now we are going to learn one big difference. Look at the codes and the comments:

1. This code will close Form1:

Private Sub btnClose_Click(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles btnClose.Click
    Me.Close()
End Sub

2. This codes will close the program:

Private Sub btnClose_Click(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles btnClose.Click
    End
End Sub

An empty form with just a button is not very informative. Today, we will limit the information on this form to one link to your e-mail address, and if you have, one link to your homepage.

Insert two link labels from the toolbox and rename them to something meaningful. I renamed LinkLabel1 to emaillink and LinkLabel2 to hplink. Decide what text you want to use. I used Mail Me! for the emaillink and Visit my homepage for the hplink. Again, you can do this within the code if you prefer, right below the property for the button.

Double-click your e-mail link and edit the code so that it looks like this one:

Private Sub emaillink_LinkClicked(ByVal sender As System.Object_
    ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgsHandles _
    emaillink.LinkClicked
    'set this property to true if you want the color to change
    'after the user clicks the link.
    emaillink.LinkVisited = True
    'Open an empty email. Make sure you write "mailto:" before
    'your e-mail address.
    System.Diagnostics.Process.Start("mailto:georg@teleon.com.br")
End Sub

Go back to design view and double-click your homepage link. Now let's edit the homepage link:

Private Sub hplink_LinkClicked(ByVal sender As System.Object_
    ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgsHandles _
    hplink.LinkClicked
    emaillink.LinkVisited = True
    'Make sure you type http: before the address. If you don't
    'it won't work.
    System.Diagnostics.Process.Start("http://www.devcity.net")
End Sub

You can test the links right from the code, just click them. If you just copy and paste the code, change at least my e-mail address. Otherwise I might get e-mails intended for you. That would not be the first time that this happens. Of course, devCity isn't my homepage, but it's a good idea where programmers could go. When you're through with that, build and run your program again and click the links.

There's another thing that bothers me. The font size is too small for my taste. If you feel the same, do the following. In design view, click each link label once and go to the properties window. Click the property Font and then the ellipsis. Change the font and/or size and/or appearance to what you think is best. In my example, I just put the default font to size eleven and the appearance to boldface. Just remember to resize your labels so that everything is completely visible.

Now let's do something many beginners are just itching to know how that works. Open the Debug folder of your program and right-click your program. Choose "Properties" and click the Version-tab. When you click each item you will see that there's almost no information. We can change that, too. Go back to your program and double-click "AssemblyInfo.vb" in the solution explorer. Type your information, but make sure that you type within the inverted commas (""). The edited parts of the assembly info could look like this:

<AssemblyAssemblyTitle("My Address Book")>
<AssemblyAssemblyDescription("This is my first program.")>
<AssemblyAssemblyCompany("Joe Blow and his mighty VB .NET")>
<AssemblyAssemblyProduct("The Address Book")>
<AssemblyAssemblyCopyright("Me, who else?")>
<AssemblyAssemblyTrademark("C'mon, I don't have that yet.")>
<AssemblyCLSCompliant(True)>

<AssemblyAssemblyVersion("1.0.0.0")>

Build the program and look at the version information again. Now it looks quite like a professional thing, doesn't it?

Before we end today, let's talk about error handling. As I told you, I won't deal with it yet because there are some things you should learn before this. I didn't say, though, that I wouldn't introduce you to the basic concepts of error handling.

Basically, error handling is supposed to deal with all kinds of potential errors. For example, a user might give wrong input, like text where the user should provide numbers. If you haven't prepared the program to deal with the error, the user will get an error message. Other things you have to prepare your program for are accidents. This could be a simple click that closes the program although the user didn't intend to do so. The accidental click is the easiest thing to fix; just put in a message box.

Let's have look at the "Close" button. The only thing that could go wrong here is an accidental click. The result, however, would be a disaster; the user would lose all data that wasn't saved. We must provide a security device so that this will become more difficult to happen. This security device can be a simple message box. Double-click the "Close" button and edit the code so that it looks like this one:

Private Sub btnClose_Click(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles btnClose.Click
    If MessageBox.Show_
        "Make sure you save your data" & _
        Microsoft.VisualBasic.ControlChars.CrLf & "before you close the " _
        & "program." & Microsoft.VisualBasic.ControlChars.CrLf & "Do you " _
        & "really want to exit?""My Address Book"_
        MessageBoxButtons.YesNo_
        MessageBoxIcon.Exclamation= DialogResult.Yes Then
        End
    End If
End Sub

When you now click to close the program, the message box will pop up and ask for confirmation. If the user clicks "yes", the program will close, if the user clicks "no", the user can return to the program and make any necessary changes. The way we did it is certainly not the best way, but it is merely meant as an introduction. That's why there isn't much of explanation to that code. The best solution here would be a code that saves all data before closing the program. Although we have a message box, many happy clickers don't even care about message boxes. Real error handling code is much larger. You will see in the future that programs can consist of more error handling code than program code.

Who knows, maybe you want to expand the basic things you have just learned about error handling to make some fun handling. Huh? What's that? You know, VB .NET is very patient; it let's you insert as many message boxes as you have fingertips to type. You could do this on All Fool's Day, for those people who mean soooo much to you.

No matter which button you click, you have to go through all of them. Ah, yes, just stop inserting messages boxes when your fingertips start bleeding, okay? Before the next All Fool's Day, we will have a real fun program working, I promise you. By the way, you already have the knowledge to make such a fun program, but I will leave that for later; I like the A-ha!-effect. Now you got curious, didn't you? One more reason to stay tuned to devCity.

One more thing to that: don't exaggerate. And since I've touched that subject: never ever use harmful code in your programs. Writing harmful code can be challenging, but it can also be easier than what you've done up to now. The following code is meant to slightly irritate some people or make them laugh, but it won't harm. After you have inserted the following code, run your program - and happy clicks! Let's double-click the Close button and edit the code:

Private Sub btnClose_Click(ByVal sender As System.Object_
    ByVal e As System.EventArgsHandles btnClose.Click
    If MessageBox.Show("Do you really want to leave me?""Sniff-sniff"_
        MessageBoxButtons.YesNo_
        MessageBoxIcon.Question= DialogResult.Yes Then
        MessageBox.Show("Are you really sure?""More sniff-sniff"_
            MessageBoxButtons.YesNoMessageBoxIcon.Question)
        MessageBox.Show("Puh-leeze, don't go!""Much more sniff-sniff"_
            MessageBoxButtons.YesNoMessageBoxIcon.Question)
        MessageBox.Show("Last chance, honey: wanna leave?"_
            "Lots of sniff-sniff and bah"MessageBoxButtons.YesNo_
            MessageBoxIcon.Warning)
        End
    End If
End Sub

Basically, you have completed a simple program. Okay, for you real beginners out there: it certainly wasn't that simple. The program comes very close to a real user application. This is meaningful and interesting programming for beginners. Many books for beginners take you through an array of individual functions, and at the end of the book you still don't have a single useful program. This doesn't make much sense to me. Well, some things are still missing. I introduced you to the basic concepts error handling, and of course, we will use it in our program - later. Finally, we must be able to install our program on another computer, right? So, stay tuned.

Related devCity.NET articles:

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:4.70000000000002 out of 5
 40 people have rated this page
Article Score31188
Comments    Submit Comment

Comment #1  (Posted by Mike N on 07/11/2003)

I have a few comments. I understand that this is essentially a beginning VB.Net tutorial. So take these comments as a learning experience, and not as criticism.

Anytime you have a "box" that is just for output, i.e. like the IDNumber field, it is better to use a Label than a textbox with enabled set to false. You can change the BorderStyle of the label to Fixed3D and change the background color to make it look like a textbox if you like. I usually just change the BorderStyle. Since it is not a textbox, it can never have the focus.

For adjusting the tab property, I have found the easiest way to do this and have visual feedback is select the form. Then click View -> Tab Order. Now click each control in the order you want the tab order to be. The tab number viewed on the screen will change as you click through the objects. Click on View -> Tab Order again to turn it off.

You may have noticed that even labels have a tab order. Why is that you may ask. It is a simple explanation. Say that you wanted to use accelerator keys to jump to a certain textbox. Even though labels cannot get the focus, if you click the accelerator key shortcut for the label, the focus changes to the next control in the tab order. So say that the label for Phone Number had the Text set to "&Phone Number" without the quotes. You will see the P in Phone Number underlined. When you run the project (assuming the Tab Order is set correctly) hitting Alt-P will jump to editPhoneNumber in your example. The magic character is the & (Shift-7). When you put that in the Text of a control, it sets the accelerator key. Exit buttons usually have the x underlined, so the text for btnExit would be "E&xit".

For ToolTips, another way to set them is as follows. I like the way you show how to do it in code (always useful to know, especially if you change them during runtime). But if the tool tips are to be "static", after you add the tooltip control from the toolbox, every control on the form gets a new property, ToolTip on ToolTip1 (or on whatever you change the name of your tooltip to). Click on a control, and in the properties, at the very bottom (assuming you did not change to alphabetical listing of properties) will be the property ToolTip on ToolTip1.

Also, instead of typing Microsoft.VisualBasic.ControlChars.CrLf, you can just type ControlChars.CrLf. I prefer using ControlChars.NewLine, but that is just preference. It does the same thing.

About forms are usually modal forms, which means that you have to close the form before you can go back to the DataForm. If you want to do that, use about.ShowDialog instead of about.Show.

One other thing that I would suggest is naming conventions. I just finished taking a VB class, which pounded naming conventions. If you have a textbox, name it so that you can tell from code what it is. Say it is an address, then use txtAddress. If I showed you a code snippet that said txtAddress.Text = "Some text", then txtAddress.Focus, you would be able to tell right away that it is a text box. Very handy when you go back to look for the control on your form that you are looking for a textbox that has something to do with the address.

Finally, don't forget to use the AcceptButton and CancelButton properties of your forms. The AcceptButton property sets which button would get "clicked" if the user pressed Enter on the keyboard. The CancelButton property sets which button is clicked if the user presses Escape on the keyboard. Very handy properties. I usually set the CancelButton to my btnExit so I can close the program by pressing Escape while I am working on a program.

These tutorials George wrote are very good. I am trying to add to them, show different ways to do things, and generally get people thinking. That is what this is all about, learning how to program and having fun doing it!
 
Comment #2  (Posted by George on 07/12/2003)

Thanks a lot for your remarks, Mike. Let me reply to them because I believe that otherwise beginners who have followed my articles may assume I’m doing the wrong things.

At this place I ought to point out that all my articles are carefully planned and tested with people who are not familiar with programming. I give my articles to those people and they have to conclude the steps without any assistance. If they do have a question, the test will be interrupted and the part in question will be rewritten so that no doubt remains. If something gets too complex, it will be omitted. All you need to complete my articles is the information from my preceding articles.

All articles are edited by qualified editors before they are published. DevCity does not put out nonsense; articles are usually of high quality. They are given a run-through, too. Slightest mistakes are detected instantly and corrected prior to publishing.

Now, let’s come to the comments:

1. Naming Conventions:
A convention is a commonly acceptable behavior. That means that people with a different behavior aren’t mistaken. In this case, I do hope the Microsoft wizards read this, too. The data access was automatically generated, and evidently Microsoft didn’t care about naming conventions. I was also surprised to see “edit” instead of “txt”. Beginners should not alter anything of the automatically generated data access as it will just produce errors over errors.

2. Anytime you have a ‘box’ that is just for output, i.e. like the IDNumber field, it is better to use a Label than a textbox with enabled set to false.

It’s automatically generated and should not be changed by beginners. Of course, if you know what you’re doing, go ahead. Besides, I for myself don’t agree with this opinion, but it’s probably a design issue. You could try to convince me if you tell me why it is better.

3. For adjusting the tab property, I have found the easiest way to do this and have visual feedback is select the form. Then click View -> Tab Order. Now click each control in the order you want the tab order to be. The tab number viewed on the screen will change as you click through the objects. Click on View -> Tab Order again to turn it off.

This way is much faster, but it’s a far cry from being easy for a beginner. All I write must be easy to grasp; so easy, that further questions might not be asked very frequently because replies can take time. The whole lot is tested with absolute beginners; one of them didn’t even know how to turn on a computer. In my tests, this didn’t work fine, so I left it out. I will come back to this in a later article.

4. You may have noticed that even labels have a tab order. Why is that you may ask. It is a simple explanation. Say that you wanted to use accelerator keys to jump to a certain textbox. Even though labels cannot get the focus, if you click the accelerator key shortcut for the label, the focus changes to the next control in the tab order. So say that the label for Phone Number had the Text set to "&Phone Number" without the quotes. You will see the P in Phone Number underlined. When you run the project (assuming the Tab Order is set correctly) hitting Alt-P will jump to editPhoneNumber in your example. The magic character is the & (Shift-7). When you put that in the Text of a control, it sets the accelerator key. Exit buttons usually have the x underlined, so the text for btnExit would be "E&xit".

Since there were problems with tab-stops for the buttons during my tests, I wrote that beginners should disable all tab-stops for the sake of simplicity. Now, the labels in this case aren’t much different, and there will be no inconsistency in my articles; that’s why this was not covered.

5. For ToolTips, another way to set them is as follows. I like the way you show how to do it in code (always useful to know, especially if you change them during runtime). But if the tool tips are to be "static", after you add the tooltip control from the toolbox, every control on the form gets a new property, ToolTip on ToolTip1 (or on whatever you change the name of your tooltip to). Click on a control, and in the properties, at the very bottom (assuming you did not change to alphabetical listing of properties) will be the property ToolTip on ToolTip1.

That is absolutely true, and by the time you have set your fifth tool tip, I will have finished twenty of them because I know how to type. The effect is absolutely the same. I find my way fast, efficient, and very intelligible. To me it’s what counts. You will see later that I do things very differently from other programmers if it’s faster and/or easier. Some of those things you will never ever find in books or courses because some people regard them as unacceptable. There’s news: the end-user doesn’t care how you did it, and if it’s easier, why do it the knotty way? It would be so great if Microsoft would incorporate wizards for simple programming routines, wouldn’t it?

6. Also, instead of typing Microsoft.VisualBasic.ControlChars.CrLf, you can just type ControlChars.CrLf. I prefer using ControlChars.NewLine, but that is just preference. It does the same thing.

Absolutely right, and I personally prefer ControlChars.NewLine. However, as I already mentioned, there will be no inconsistency in my articles. If you look in the help files, you will mostly find them the way I did. If a beginner goes for the help files just to check something and finds things a much different way; that would prove inconsistency; that can’t be good for me as a teacher with ten years on the job.

7. About forms are usually modal forms, which means that you have to close the form before you can go back to the DataForm. If you want to do that, use about.ShowDialog instead of about.Show.

Right, but my point here was how to show a second form, not a modal form; a beginner might want to use it for other things than an about-form. This project is meant as an introduction for something more complex with two forms. That’s why I did it that way. Also, showing an about-form in this way is not wrong, just different. Programming is like English: neither will accept fixed rules.

8. Finally, don't forget to use the AcceptButton and CancelButton properties of your forms. The AcceptButton property sets which button would get "clicked" if the user pressed Enter on the keyboard. The CancelButton property sets which button is clicked if the user presses Escape on the keyboard. Very handy properties. I usually set the CancelButton to my btnExit so I can close the program by pressing Escape while I am working on a program.

This is merely a matter of consistency. If I don’t deal with button tab-stops, I won’t deal with those properties either. Be assured, the tab-stops and this will come in a later article.

9. These tutorials George wrote are very good. I am trying to add to them, show different ways to do things, and generally get people thinking. That is what this is all about, learning how to program and having fun doing it!

Thanks for the flowers. Your comments are very much appreciated. I just felt I had to give my reasons.

 
Comment #3  (Posted by Mike N on 07/15/2003)

This is an open reply to George, and anyone else reading this.

As you learn programming, you will quickly see that everyone has their own "style" of programming. Even the books and classes you can take fall victim to this. One book for my latest class pitched all the naming conventions that are supposedly MS recommended. It drove me nuts having points taken off a lab exercise because I forgot in one instance to use their conventions, even though it did not affect the program operation at all. As you gain experience, there will be people who critize you just because of the style you use when you program.

That said, I wanted to point out that I was not trying to be critical of George, or the way he wrote this article. I was simply trying to show different ways of doing things. There are always numerous ways to accomplish the same thing. I never meant to imply that I thought George was doing things the wrong way. As I said, I was merely trying to point out another "right" way.

Keep up the good work George!
 
Comment #4  (Posted by George on 07/17/2003)

Thanks a lot, Mike. I understood your intention perfectly well; I just replied because I thought some people might misunderstand this. Your second comment clears any remaining doubts. Very much appreciated.

 
Comment #5  (Posted by Pat664422 on 01/24/2004)

George,

Thanks for devoting your time to creating and testing these introductory articles. It's giving me a chance to reinforce what I'm learning in books, and practicing it in programs larger than just one or two functions is very beneficial. I agree with you that introductory books would do much better to have their readers work and build on two or three large programs as they go through the book instead of creating a small new program at the end of every chapter.

Patrick
 
Comment #6  (Posted by Bob on 04/16/2004)

I am enjoying working on this and I am finding it is easy to make mistakes in typing but the debugging is pretty good. Thanks for the excellent work in putting together this series, George.
 
Comment #7  (Posted by Buzzark on 01/10/2005)
Rating
Another great beginner article - thanks.

I also think that the little banter between Mike and George serves as a little lesson by itself and will help new programers understand that right and wrong ways aren't always clearly defined in programming.

Good comments from Mike, good explanations for the reasons behind doing things "that way" from George.
 
Comment #8  (Posted by an unknown user on 04/19/2005)
Rating
thanx, your article has been very useful
 
Comment #9  (Posted by Robert Kirchhof on 05/20/2005)
Rating
I like everything I've read and learned through these articles. I've come a long way in a short time, and I know what I've learned is going to serve me well in my VB.Net endeavors. Thanks.
 
Comment #10  (Posted by an unknown user on 12/15/2007)
Rating
Thanks a lot for your time devoted to newbies like me!
 
Comment #11  (Posted by an unknown user on 12/15/2007)
Rating
Thanks a lot for your time devoted to newbies like me!
 
Comment #12  (Posted by an unknown user on 04/25/2009)
Rating
Badly need your help. Do what you feel in your heart to be right - for you'll be criticized anyway. You'll be damned if you do, and damned if you don't.
I am from Oman and now study English, give please true I wrote the following sentence: "Fund raising with unique kitchen clocks or kitchen wall clocks with photos of your pets, family, new car."

Thank :-( Umi.
 
Comment #13  (Posted by Buy OEM software online on 09/29/2011)
Rating
dtUflk Yeah, in my opinion, it is written on every fence!!...
 
Sponsored Links