EXCEL VBAメモ - 変数
変数の宣言は1つずつ
以下の変数aは、Integerにならない。
Dim a, b As Integer MsgBox TypeName(a) '-> Empty MsgBox TypeName(b) '-> Integer Dim a As Integer, b As Integer '正しい書き方
変数は宣言時に初期化はできない
以下の様に記述する。
Dim a As Integer: a = 0
整数型はLong型(4byte)
Integer型(2byte)は現在のPCでは却って遅くなる場合も。
リテラルの型文字
Integer % Long & Single ! Double # Currency @ String $
スタティック変数の初期化方法
Static foo As Range If foo Is Nothing Then do_initialize End If