次のように式を作成して、値を変数に割り当てます: 変数は式の左側、変数に割り当てる値は右側に配置します。
次の例は、変数への値の割当ての使用方法を示しています:
例1:
B = 200 'Assigns the value 200 to the variable B. Dim A A = 100 'Assigns the value 100 to the variable A.
例2:
Dim Name Name = "Alice" ' Assigns the string "Alice" to the variable Name.
例3:
Dim IsActive IsActive = True ' Assigns the Boolean value True to the variable IsActive.
例4:
Dim X, Y, Z X = 5 Y = 10 Z = X + Y ' Assigns the result of the expression (X + Y) to the variable Z.
例5:
Dim CurrentDate CurrentDate = Date ' Assigns the current system date to the variable CurrentDate.
例6:
Dim A, B A = 200 ' Assigns the value 200 to the variable A. B = A ' Assigns the value of A to the variable B.