PRB: Using Reserved Keywords as TypesLast reviewed: December 13, 1996Article ID: Q129448 |
The information in this article applies to:
SYMPTOMSYou 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.
RESOLUTIONThe solution is to not use reserved keywords as types.
STATUSThis behavior is by design. MORE INFORMATION
Steps to Reproduce the Problem
A list of Visual Basic reserved keywords is shown below.
List of Reserved Keywords
And Function PsetOr Any Get Private As Global Public ByVal GoSub ReDim Call GoTo Rem Case If Resume Close Imp Return Const Let RSet Debug Like Set Declare Local Static Dim Loop Stop Do Lset Sub Each Me To Else New True Elseif Next Type End Not Typeof Endif Nothing Until Erase Null Wend Eqv On While Exit Open With False Option Xor For |
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |