Visual Basic for Applications/Variables
This lesson introduces variables.
Objectives and Skills edit
Objectives and skills for using variables include:
- Declaring variables by using the appropriate data types
- Making variables available to procedures in all modules of an application
- Performing actions with built-in and user-defined constants
Readings edit
Multimedia edit
Examples edit
'This macro accepts user input and then displays double the value entered.
Option Explicit
Sub DoubleValue()
Const Title = "Double Value"
Dim Value As Single
Dim Result As Single
Value = InputBox("Enter a value:", Title)
Result = Value * 2
MsgBox Value & " * 2 = " & Result, vbOKOnly + vbInformation, Title
End Sub