vel4p02






Visual Basic 4 in 12 Easy Lessons vel4p02.htm













Visual Basic 4 in 12 Easy Lessons vel4p02.htm
























The Program's Description



The Program's Action



That's It for Now









Project 2









Visual Basic Programs



Stop and Type: This lesson discussed the controls and properties of Visual Basic programs. The properties determine the look and behavior of the controls; the controls let the user interact with the program. When you write Visual Basic programs, you should follow as many standards as you can so that you can minimize any subsequent maintenance. You also learned





To use good judgment when you design applications so that you do not use several controls that would only make the application look too busy.





To use standard three-letter prefix abbreviations when you name a control so that you know from its name exactly what kind of control you are working with.





To follow Windows programming standards so that your application looks and behaves like other Windows applications. That way, the user will be familiar with your programs and will be more likely to learn and use the programs that you write.







The projects at the end of each lesson in this book show the creation of a Visual Basic program. They demonstrate the concepts taught in each unit. You have only scratched the surface so far. Beginning with the next lesson, you will start learning the details of controls and properties. So far, you have seen only how to place and activate the label and command button controls. There is much more to learn about these and the other controls. For this project, focus on following the instructions to gain more insight and practice in using Visual Basic.











The Program's Description



Figure P2.1 shows the first screen of the application described in this project. The application is simple and easy to implement if you follow the instructions that come next.



Figure P2.1. Getting ready to view different properties.



The purpose of the Project 2 program is to show you the various properties that are possible for labels. Lesson 3 explores the label control's properties in detail, but you are already versed enough in Visual Basic to understand the properties demonstrated by this program.











The Program's Action



The program first displays a label in the center of the screen. The label's border shows that the label is wide. The text in the center of the label is small, and the label's background color is white. Click the Next Property command to see a different set of properties.



The property changed by your first command button click is the alignment. A label can be left-justified, centered, or right-justified inside its placed width. The label began as a centered label, but you now see a left-justified label.



Click Next Property again. The label takes on the right-justified alignment property.



Clicking the Next Property button once more returns the label to the centered alignment and changes the property's font size to a big font. As you click the Next Property button, you will see that the label updates to show you the changed property.



To see the label's background color change, click Next Property again. The background of the label turns bright green. (Wear your sunglasses.)



Click the Next Property command button once more to see the final label property change. As Figure P2.2 shows, the width of the label shrinks to a smaller size. When you click the Next Property command button again, the label returns to its original size, font, and color property values.



Figure P2.2. The width property got smaller.











Note: This project's application contains a command button event procedure that changes all the properties whenever the user clicks the Next Property command button. This project does not list the code for that event procedure because the code would make absolutely no sense at this point in the book. If you really want to see the code, scroll through the Code window after you start the program.















That's It for Now



You can now exit the program by clicking the Exit command button. The application quits running, and you will return to the Visual Basic development environment.


















Wyszukiwarka