150 likes | 289 Views
Tutorial 6. Introducing Variables, Memory Concepts & Arithmetic. Variables. Holds data Controls for Design Programming, Variables for Code Programming Text Property Data Variable Manipulate data w/o showing to users Store data w/o adding or using controls
E N D
Tutorial 6 Introducing Variables, Memory Concepts & Arithmetic
Variables • Holds data • Controls for Design Programming, Variables for Code Programming • Text Property Data Variable • Manipulate data w/o showing to users • Store data w/o adding or using controls • Hold numbers, data & time, text, and etc. Continue
One type of variable can take the same type of data. E.g. • intCount = 15 (OK) • intCount = “Pat” (not OK) • intCount = “15” (not OK) • Must be declared. E.g. • Dim intCount As Integer • Dim sngPrice As Single Continue
Steps of Using Variables • Declare • Input: Assign a value by reading in from a control or other source • Process: Use or manipulate • Output: Put the value to a control or other object
Example 1: Dim intTotal As Integer intTotal = Val(txtTotal.Text) intTotal = intTotal + 10 txtTotal.Text = Str(intTotal)
Example 2: Dim intTotal As Integer Dim intExtra As Integer intTotal = Val(txtTotal.Text) intExtra = 10 intTotal = intTotal + intExtra txtTotal.Text = Str(intTotal)
Example 3: Dim intTotal As Integer Dim intExtra As Integer = 10 intTotal = Val(txtTotal.Text) intTotal = intTotal + intExtra txtTotal.Text = Str(intTotal)
Integer • Stored as 32-bit (4-byte) integers ranging in value from -2,147,483,648 through 2,147,483,647. • Provides optimal performance on a 32-bit processor, as the smaller integral types are slower to load and store from and to memory. • You can convert the Integer data type to Long, Single, Double, or Decimal without encountering a System.OverflowException error.
Single • Stored as IEEE 32-bit (4-byte) single-precision floating-point numbers ranging in value from -3.4028235E+38 through -1.401298E-45 for negative values and from 1.401298E-45 through 3.4028235E+38 for positive values. Single-precision numbers store an approximation of a real number. • Can be converted to the Double or Decimal data type without encountering a System.OverflowException error.
String • Stored as sequences of 16-bit (2-byte) numbers ranging in value from 0 through 65535 • Each number represents a single Unicode character. A string can contain up to approximately 2 billion (2 ^ 31) Unicode characters • The first 128 code points (0–127) of Unicode correspond to the letters and symbols on a standard U.S. keyboard • The second 128 code points (128–255) represent special characters, such as Latin-based alphabet letters, accents, currency symbols, and fractions • The remaining code points are used for a wide variety of symbols
Arithmetic Operators Continue
Using Debugger • Demo