From MSDN (http://msdn.microsoft.com/en-gb/library/y9341s4f%28v=vs.80%29.aspx)
"When Option Explicit appears in a file, you must explicitly declare all variables using the Dim or ReDim statements."
So ReDim works in Option Explicit.
Domanda
Does anyone know why this doesn't throw a Variable not defined
error when I compile it?
'Class1.cls'
Option Explicit
Public Sub foo()
ReDim fubar(1 To 2, 1 To 1)
End Sub
Am I misunderstanding how Option Explicit
is supposed to work? Or is there something wrong with this test? Or is this just a bug in VBA?
(I am testing this on Excel 2007)
Soluzione
From MSDN (http://msdn.microsoft.com/en-gb/library/y9341s4f%28v=vs.80%29.aspx)
"When Option Explicit appears in a file, you must explicitly declare all variables using the Dim or ReDim statements."
So ReDim works in Option Explicit.