Microsoft KB Archive/141076

= How to Change a Method at Run Time =

Article ID: 141076

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q141076



SUMMARY
All methods are read-only at run time. You can, however, have several methods and decide at run time which method to execute. This article shows you how.



Step-by-Step Example
 Create a new form.  Place a command button (Command1) on the form, and add the following code to its Click event: lcTemp=ThisForm.gcCurrentclk &lcTemp   Place an Option Group on the form, and add the following code to its Click event: IF This.Value=1 ThisForm.gcCurrentclk="ThisForm.Click1" ELSE ThisForm.gcCurrentclk="ThisForm.Click2" ENDIF  Create a new form property called gcCurrentclk, and assign ThisForm.Click1 to gcCurrentclk.  Create a new Form method called Click1, and place the following in the Form.Click1 method: WAIT WINDOW "Click #1"   Create a new method called Click2, and place the following code in the Form.Click2 method: WAIT WINDOW "Click #2"  Run the form.</li></ol>

The option group determines which Click method for the command button will execute.

NOTE: The Click event for the command button does not have to be a method of the current form. For example: gcCurrentclk="DO myprog.PRG" would execute a program. gcCurrentclk="oMyclass.Click1" would execute a method of an external class. gcCurrentclk="WAIT WINDOW" would execute a wait window.

Additional query words: VFoxWin

Keywords: KB141076

-

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

© Microsoft Corporation. All rights reserved.