Microsoft KB Archive/129935

= PRB: Non-Reserved Word w/ Colon Behaves Differently in VB 4.0 =

Article ID: 129935

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q129935



SYMPTOMS
Using Non-reserved keywords followed by a colon may produce different results in Visual Basic version 4.0.

A reserved keyword in Visual Basic cannot be used as the name of a user-defined function. However, a non-reserved keyword may be used as the name of a user-defined function.

In Visual Basic version 4.0 a non-reserved word followed by a colon is interpreted as a line label. Previous versions of Visual Basic checked to see if this is a statement followed by another statement on the same line.

Similar behavior occurs when you use a user-defined subroutine with no parameters followed by a colon and another statement.



RESOLUTION
To avoid the confusion that this could potentially cause, Microsoft recommends that you use colons only for line labels. Write each individual statement on a separate line. Not only does this allow you to avoid confusion, it also makes your code easier to read.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default. Place a command button (Command1) on the form.  Place the following code inside the Command1 click event: Print "Hello" Cls: Beep  Run the program by choosing Start from the Run menu. Click the Command1 button.</ol>

In Visual Basic version 4.0, the word Hello is printed on the form and a beep sounds. In previous Visual Basic versions, Hello is printed, and then erased; then the beep sounds.

Additional query words: 4.00 vb4win vb4all

Keywords: kbprb KB129935

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.