PRB: Using Reserved Keywords as Types (129448)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
- Microsoft Visual Basic Enterprise Edition for Windows 4.0
This article was previously published under Q129448 SYMPTOMS
You can use reserved keywords as types when declaring object variables;
however, this practice should be avoided. If the environment setting for
"Auto Syntax Check" is turned on, you will receive either the error
"Expected: New or type name" or "Expected: type name," depending on whether
or not you declare variables with the "New" keyword.
You can work around the syntax checker by placing square brackets ([])
around the reserved keyword; however, Visual Basic will remove the square
brackets from the code window. Consequently, editing any part of the line
of code that had square brackets causes the code to be invalidated again by
the syntax checker. Furthermore, if you save a project and reload it at a
later time and attempt to execute the program, you will receive the error
"Syntax error" until you add the square brackets back in.
CAUSE
Because of the way Visual Basic internally handles the name of user defined
types, the square brackets cannot be preserved and are removed.
RESOLUTION
The solution is to not use reserved keywords as types.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbprb KB129448 |
---|
|