How to Scope Variable Declared in Event CodeID: Q138680 The information in this article applies to:
SUMMARYA variable declared in event code is not visible outside that code unless the variable is declared Public or you crate a new form property.
MORE INFORMATIONVariables declared in event code for objects are only visible to those objects at the time the event code is running. There are two ways to make variables visible to code outside a specific event.
Method OneDeclare the variable Public. To do this, add the following line of code to the Load event of your form:
Method TwoCreate a custom property of the form. To do this, follow these steps: 1. Create a form. 2. On the Form menu, click New Property. 3. In the Name box, type X. 4. On the Other tab of the form's Property sheet locate your new property 5. Type the words, "Hello World" (without the quotation marks), and press
6. Add a command button to your form.
7. In the Click event of the command button, enter the following line of 8. Run your form.
9. Click the command button. The wait window displays: Hello World.
Step-by-Step Example1. Create a form. 2. In the Load event of the form, add the following line of code:
3. Add a command button to your form.
4. In the Click event of the command button, add the following line of Additional reference words: 3.00 VFoxWin
KBCategory: kbtool kbhowto kbcode
KBSubcategory: FxtoolFormdes
|
Last Reviewed: October 29, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |