Here you got an error in your code because i was undefined. And that should be fixed with Option Explicit - if we were in pure vb .
This is a common declaration problem in which we accept vba will read
Dim i,e as long
as
Dim i as long Dim e as long ...
Unfortunately, this is not the case. This is weird because it is different from how it works in vb
Declaring multiple variables
You can declare several variables in one declaration by specifying a variable name for each of them and after each array name with parentheses. Several variables are separated by commas.
Dim lastTime, nextTime, allTimes() As Date
In VBA, to verify the type , we can check the type of the variable in this way using TypeName :
Sub getTypes() Dim i, e As Long MsgBox "i: " & TypeName(i) MsgBox "e: " & TypeName(e) End Sub
give:
i: Empty e: Long
source share