Download presentation
Presentation is loading. Please wait.
Published byMelvin Hicks Modified over 8 years ago
1
Visual Basic 6 Programming Decide how many variables you need by looking at this form. There is one textbox for input and there are 3 labels for output, so you need 4 variables in all Textbox names should start with txt Labels names should start with lbl Command button names should start with cmd
2
Visual Basic 6 Programming Numeric variables should start with sgl (for single) Text variables should start with str (for string) TxtPrice will have a corresponding variable sglPrice LblGST will have a corresponding variable sglGST LblPST will have a corresponding variable sglPST LblTotal will have a corresponding variable sglTotal Variable & Object Naming Conventions
3
Visual Basic 6 Programming Variables section Dim sglPrice as single 'this is to store the price Dim sglGST as single Dim sglPST as single Dim sglTotal as single Use an apostrophe to make comments: 'This is a comment it will appear green Variables are locations in the computer memory Objects on the form (textboxes etc) are what the user interacts with.
4
Visual Basic 6 Programming INPUT section This is where the input the user types into a textbox is passed onto the variable In order to convert text from the textbox into a number, you use the val() function: SglPrice = val(txtPrice.text) strName = txtName.text strName = “Joe” ‘Notice the double quotes around Joe DO NOT use val if you are assigning a value to a text variable (string variable)! Notice the variable getting assigned a value is always on the left side of the = sign
5
Visual Basic 6 Programming Calculation section should only use variables (just like in math!) There are 3 calculations in this case sglGST = sglPrice * 0.05 sglPST = sglPrice * 0.05 sglTotal = sglPrice + sglGST + sglPST Again, notice that the variable being assigned a value MUST be on the left side of the = sign. DON’T use OBJECTS in this section (txt or lbl)
6
Visual Basic 6 Programming OUPUT Section You will now have to output the 3 output variables to the 3 corresponding labels lblGST.caption = sglGST lblPST.caption = sglPST lblTotal.caption = sglTotal
7
TxtPrice LblTotal LblPST LblGST This program responds to the change event. When the user types in something into the textbox, the program executes.
8
Visual Basic 6 Programming Reminders Textboxes have a text property Labels, Command buttons, and Forms have a caption property
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.