Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Interactive Messageboxes
Message
From
05/08/2000 23:01:18
 
 
To
05/08/2000 20:18:06
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00401589
Message ID:
00401614
Views:
21
>Hi Alex,
>
>Thanks for responding.
>
>I guess that's the trick I need...what code would I use to return the text typed in - say for instance to put the text in a textbox on the main form?
>
>(The reason I like this is that it forces the user to enter the ID number first, that way it's not so messy and the record he's working on is secure)
>

If it's a single value to return, and the input form is modal, use the ability of a modal form to return a value:

DO FORM MyModalInputMessageBox TO cMyReturnValue

When designing the form MyModalInputMessageBox you want to create a Modal form (WindowType = 1), and create a Form property to serve as the ControlSource for the input textbox in the Modal form; it's important to save the value here rather than relying on the textbox's .Value property, because controls owned by the Form have been released prior to the Unload firing. For purposes of this example, I'll assume you created a form property cMyValueToReturn, and initialized it to an empty string ( using =SPACE(0) in the property sheet works well for this.) In order to use DO FORM, you must create the form as a FORM (.SCX) rather than as a class.

In the Unload Event of MyModalInputMessageBox, you can return a single value by including the value to pass back in the RETURN:
FUNCTION UNLOAD
   RETURN Thisform.cMyValueToReturn
ENDFUNC
On returning from the modal form, the variable cMyReturnValue of the method of the calling form will be filled with the value from the RETURN. Make certain to save this value to the ControlSource you want to fill, since the variable will dispapear when the method call terminates. Sticking it into a property or the underlying table field allows the value to persist beyond the method call.

The advantage of this over Barbara's approach is that the coupling between the input messagebox form and the calling form is reduced; if you pass a form reference and explicitly fill a property via the form reference, you can only reuse the form if a similar object is passed - the Modal form with the single return value could be reused without owrrying about the exact nature of the caller.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform