E N D
Variable Exercises Chapter 3 Chapter 3 Part 2
Example 1 Const intTWO As Integer = 2Const intFIVE As Integer = 5Dim intA As IntegerDim intB As IntegerDim intC As IntegerintC = intA + intBintB = intB + intTWOintA = intTWO * intFIVEintB = intA – (intTWO + intFIVE)intA = intA + intAintC += intAintB -= intA lblOutput.Text = intB Chapter 3 Part 2
Example 2 Dim sngTestA As Single Dim sngTestB As Single Dim sngTestDifference As Single sngTestA = 2.3456789 sngTestB = 1.2345678 sngTestDifference = sngTestA – sngTestB What would be stored in TestDifference if 3 variables are Decimal? Long? Double? Chapter 3 Part 2
Example 3 'Class-level declaration Dim dblSubtotal as Double 'Event Procedure Private Sub btnFirst_Click…Dim dblAmount As DoubleDim intQuantity As Integer'Code stores user input: 10.50; 3dblSubtotal += (dblAmount*intQuantity) End Sub 'Event Procedure Private Sub btnSecond_Click…Dim dblExtPrice As DoubleDim intQuantity As Integer'Code stores user input: 5.25; 4dblSubtotal += (dblExtPrice * intQuantity) End Sub Chapter 3 Part 2