Microsoft KB Archive/129930

= PRB: Compile-Time Error Occurs Instead of Run-Time Error =

Article ID: 129930

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 Q129930



SYMPTOMS
Setting a read-only property gives you a compile-time error instead of a run-time error. This behavior represents a new feature in Visual Basic version 4.0.



CAUSE
Visual Basic version 4.0 checks to see if read-only properties are being written to at compile time. That is why Visual Basic version 4.0 checks for this type of error when you select Make EXE File from the file menu, as opposed to just reporting the error at run time.

This also occurs when Running the program in the Design Environment (with Compile On Demand turned off). By using this new feature, the compiler prevents accidental writes to read-only properties. Having the compiler catch this type of error also stops the error from crashing a program during run time.



Steps to Reproduce Behavior
 Start a new project in Visual Basic. Form1 is created by default. Place a Combo Box on Form1.  Add the following code to the click event of Form1: Combo1.Style = 2  Choose Make EXE File from the File menu. In the Make EXE dialog box, enter a name for your executable, and click OK. This results in the following error:

Function call on left-hand side of assignment must return Variant or Object



Additional query words: 4.00 vb4win vb4all

Keywords: kbprb KB129930

-

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

© Microsoft Corporation. All rights reserved.