How to: Move Data Into and Out of a Variable - Visual Basic (original) (raw)

You store a value in a variable by putting the variable name on the left side of an assignment statement.

Putting Data in a Variable

To store a value in a variable

alpha = (beta * 6.27) / (gamma + 2.1)  

The value generated on the right side of the assignment statement is stored in the variable.

Getting Data from a Variable

You retrieve a variable's value by including the variable name in an expression.

To retrieve a value from a variable

counter = startValue  
cellValue = (counter + 5) ^ 2  

The value of the variable participates in the expression just as a constant would, and then it is stored in the variable or property on the left side of the assignment statement.

See also