Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 190271 - Last Review: December 1, 2003 - Revision: 2.0
PRB: No Error When Dimming a Variable That Already Has a Value
This article was previously published under 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".
Steps to Reproduce Behavior
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."
APPLIES TO
- Microsoft Visual Basic, Scripting Edition 1.1
- Microsoft Visual Basic, Scripting Edition 2.0
- Microsoft Visual Basic, Scripting Edition 3.0
- Microsoft Internet Explorer 3.0
- Microsoft Internet Explorer 3.01
- Microsoft Internet Explorer 3.02
- Microsoft Internet Explorer 4.0 128-Bit Edition
- Microsoft Internet Explorer 5.0
- Microsoft Internet Information Server 3.0
- Microsoft Visual InterDev 1.0 Standard Edition
- Microsoft Active Server Pages 4.0
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate