Zebra0.com

visual-basic variables

A variable is a named location in memory. A variable allows us to store data that is input or calculated. Variables can vary, or change.

Before a variable can be used, it must be declared. To declare a variable, first decide what type of information you want to store:

After deciding on the type, the next thing a programmer must do is decide on a variable name.

Variables are declared with the keyword Dim. Some variable declarations are shown below:

Dim numPackages As Integer = 12
Dim message As String = "Hello World"
Dim ready As Boolean = False
Dim hourlyRate As Double = 12.25
Dim grade As Char = "A"

In addition to the types listed above you will also sometimes declare variables to be one of the special types built-in to Visual Basic:

Dim myFavColor As Color = Color.Pink

NEXT: Variables