110 likes | 202 Views
Creating a Visual Basic Program. Where to start…. These buttons toggle between the code and this form. This holds the properties of each label, command and button. This toolbox will help you create text boxes, labels, command buttons, check boxes and option boxes.
E N D
Creating a Visual Basic Program Where to start….
These buttons toggle between the code and this form This holds the properties of each label, command and button This toolbox will help you create text boxes, labels, command buttons, check boxes and option boxes
Step 1. Create the form how you wish Examples of each item often used to create forms From within the properties frame, change the name, caption, picture, visibility, font, border-style or value
Step 2. Name each item and include an appropriate caption or picture if necessary. Each name must have the appropriate prefix, then finish the name using a capital letter so it is easier to see. Frames – fra Label – lbl Textbox – txt Form – frm Command – cmd Checkbox – chk Option – opt Image – img
Naming conventions Label lblName Command buttons cmdCalculate Text box txtName Label with different Border Style lblMessage
For the command, cmdExit, the caption E&xit will create a command button Exit so users can type Alt-X to exit. Set cmdExit Cancel to true Set cmdShow Default to true
Step 3. Add code Clicking twice on each item will bring up the code screen. Then add the specific code. VB uses Object.Property=value to assign properties. In this case, it is lblShow.Caption= “The time is….”
You must put comments (called remarks) into your program so you can understand it later, or so others can read it. Placing a ‘ tells the computer to ignore the line and allows you to place remarks.
To save your program • Create a folder for each unit • Place the program in this folder with an appropriate name- frmExample is a good title, frm1 is not. • For tests, create a folder called NameTest1 and place the test within that folder
When you are done, click on the to run the program All programs are finished when your program works, you have a fully labeled diagram in your binder and pseudo-code. Pseudo-code is a shorthand written version of your code. As you create the form, you also label a picture so you know what each item is called. Then you do the pseudo-code. ONLY THEN do you create your program code.