Now that you have the HelloUser form defined, you have to add some code to make it actually do something interesting. You have already seen how easy it is to add controls to a form. Providing the functionality behind those on - screen elements is no more difficult. To add the code for a control, you just double - click the control in question. This opens the code editor in the main window, shown in Figure 17.
Note that an additional tab has been created in the main window. Now you have the Design tab and the Code tab, each containing the name of the form you are working on. You draw the controls on your form in the Design tab, and you write code for your form in the Code tab. One thing to note here is that Visual Studio 2008 has created a separate file for the code. The visual definition and the code behind it exist in separate files: HelloUser.Designer.vb and HelloUser.vb . This is actually the reason why building applications with Visual Basic 2008 is so slick and easy. Using the Design view you can visually lay out your application, and then, using Code view, you add just the bits of code to implement your desired functionality.
Note also that there are two combo boxes at the top of the window. These provide shortcuts to the various parts of your code. Hover your mouse on the combo box on the left, and you ’ ll see a tooltip appear, telling you that it is the Class Name combo box. If you expand this combo box, you will see a list of all the objects within your application. If you hover your mouse on the combo box on the right, you ’ ll see a tooltip telling you that this is the Method Name combo box. If you expand this combo box, you will see a list of all defined functions and subroutines for the object selected in the Class Name combo box. If this particular form had a lot of code behind it, these combo boxes would make navigating to the desired code area very quick — jumping to the selected area in your code. However, since all of the code for this project so far fits in the window, there are not a lot of places to get lost.
No comments:
Post a Comment