100 likes | 212 Views
This guide provides an overview of variable declaration using the 'Dim' keyword in programming. Learn how to name variables properly, ensure they are within character limits, and how to set data types like Integer, Double, Currency, and String. It includes examples such as Dim intA As Integer and workflows for better code readability and modification. Additionally, explore how to gather user input through various controls like text boxes and radio buttons, and understand basic integer arithmetic operations with examples.
E N D
Declaring Variables Dim <variable name> As <data type> Variable Name (identifier) • Begin with a letter • Only letters, digits, and the underscore _ • Fewer than 255 characters
Examples • Dim intA As Integer • Dim dblTaxRate As Double • Dim TaxAmount As Currency • Dim MyName As String
Constants • Make program easier to read dblArea = dblRadius * dblRadius * 3.14 dblArea = dblRadius * dblRadius * dblPi • Make program easier to modify dblTotal = dblPurchase * .06 dblTotal = dblPurchase * dblTaxrage
Getting Input from the User • Text box • Radio Buttons • Check Boxes Example:
Integer Arithmetic: \ • the “\” returns the integer part of division • 7 \ 2 return 3 • 12 \ 5 returns 2 • 35 \ 7 returns 5 • 35 \ 6 returns 5
Integer Arithmetic: Div • The Mod operator returns the remainder of division. • 7 Mod 2 returns 1 • 12 Mod 5 returns 2 • 35 Mod 7 returns 0 • 35 Mod 6 returns 5
Using Option (Radio) Buttons • Use when you want to force the user to make EXACTLY one choice Example