There are many times when we need our programs to store values for later use. We store values in 'variables' so that we may access their values whenever we need them.
We are going to edit our Payroll program to store the hours, hourly pay and total pay in variables.
Make sure to give variables meaningful names, and use the proper prefix for the type of data that they will store.
Dim intAge as Integer 'Declare the variable intAge = 15 'Assign a value to the variablelblOutput.Text = "You are " & intAge & " years old!" 'Use variableDim dblPrice as Double 'Declares variables that can store decimal numbersDim dblTax as DoubleDim dblTotal as DoubledblPrice = 10.99 'Assigns values to dblPrice and dblTaxdblTax = 1.13dblTotal = dblTax * dblPrice 'Calculates final pricelblTotalPrice.Text = "$" & dblTotal 'Outputs final price with '$' in frontDim strName as String 'Declare variable that can store wordsstrName = "Mr. Aldworth" 'Assign a value to variable using " "lblGreeting.Text = "Welcome " & strName 'Use variable to output a nice greetingWe are going to edit our Payroll program to display our monetary values as properly formatted currency.
If you finish, attempt the VB Color Application for bonus marks.