Microsoft KB Archive/180494

= BUG: Private Variables in a Module Are Public =

Article ID: 180494

Article Last Modified on 3/11/2005

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0
 * Microsoft Windows CE Toolkit for Visual Basic 6.0

-



This article was previously published under Q180494



SYMPTOMS
When a variable is declared in a module as Private, it is seen throughout the project as if it were declared Public.



RESOLUTION
Take care when declaring form variables and module variables so that the wrong variable is not inadvertently addressed.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new Windows CE project in either eMbedded Visual Basic or Visual Basic 6.0. Form1 is created by default. Add a module to the project.  In the module, add the following line of code: Private myMessage  Add a command button to Form1.  Paste the following code into Form1: Option Explicit Private Sub Command1_Click myMessage = "myMessage is set" MsgBox myMessage End Sub  Press F5 to run the project and note that the Click event has full access to the module's private variable. The expected behavior is to get the message "Variable not defined."</li></ol>

(c) Microsoft Corporation Mike Dixon, All Rights Reserved. Contributions by 1999, Microsoft Corporation.

Additional query words: wince vbce vbce6 evb

Keywords: kbbug kbtoolkit kbpending KB180494

-

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

© Microsoft Corporation. All rights reserved.