1 / 8

Visual Basic 6 Programming

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

kermit
Download Presentation

Visual Basic 6 Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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)‏ Variable & Object Naming Conventions 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

  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. This program responds to the change event. When the user types in something into the textbox, the program executes. TxtPrice LblGST LblTotal LblPST

  8. Visual Basic 6 Programming Reminders • Textboxes have a text property • Labels, Command buttons, and Forms have a caption property

More Related