PRB: No Error When Dimming a Variable That Already Has a ValueID: Q190271
|
In VBScript, when a variable is dimmed that already has a value assigned to it, no error appears.
This behavior is by design.
The following VBScript function, when executed, does not produce an error regarding duplicate declaration, on the statement "dim y".
sub test()
y = 8 ' a value is assigned to y
dim y ' y is dimmed, this would cause an error in VBA
msgbox y
end sub
In VBScript, this runs with no error. In Visual Basic for Applications
(VBA), however, you get a compile error on the line "dim y" saying
"duplicate declaration in current scope."
Additional query words: Error dim duplicate
Keywords : kbIE300 kbIE301 kbIE400 kbScript kbVBScript kbIE302 kbIE500
Version : WINDOWS:1.0,2.0,3.0,3.01,3.02,4.0; WINNT:1.0,1.0b,3.0
Platform : WINDOWS winnt
Issue type : kbprb
Last Reviewed: April 30, 1999