1 / 4

Variable Exercises

Variable Exercises. Chapter 3. Example 1.

grady
Télécharger la présentation

Variable Exercises

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. Variable Exercises Chapter 3 Chapter 3 Part 2

  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

  3. 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

  4. 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

More Related