Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I return a value from a class?
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00060139
Message ID:
00060374
Views:
28
Yes. Only that you should not release the form before you get from it what you wanna get. (The next line will execute also if you hide the form.)

Vlad

>Thanks for your help.
>
>It finally became clear to me...That the form of my class is modal. So I can create the object, show the object and the next line of code in the calling method will not execute until the class is released or hidden? Am I on the right track here?
>
>Thanks again,
>
>Paul
>
>>If you instantiate the object using oMyCalendar = createobject("MyCalendar"), and oMyCalendar is a local/private variable, then oMyCalendar will be released when the method/proc/func (that owns it) will finish. This will also release the object created with createobject().
>>
>>So, if the OK button of your frmCalendar doesn't release the form, you can use any method/property of the frmCalendar in the method where you create it. If you need to create it in one method and access methods/properties from a different method, then oMyCalendar can be a property to the caller form. You can release the object using ThisForm.oMyCalendar = .f. (or .NULL. or any other value). When you change the value of a property/method that keeps a reference to an object, the object is released.
>>
>>In the OK click method you don't need to release the calendar form. You can hide it (Visible = .f.) and release it later, when no longer needed.
>>
>>Vlad
>>
>>>Sorry to be boneheaded about this...I understand what you are saying here. My class frmCalendar has a calendar that they select a date and then click a commandbutton that says . The click event of this commandbutton saves the value selected, to a property of the form and then releases the form.
>>>
>>>Should I be doing something different? Or how do I know from within the form that creates the instance of this class, when to grab the property?
>>>
>>>>oMyCalendar = createobject("MyCalendar")
>>>>
>>>>After that you can call any method using:
>>>>oMyCalendar.AMethod()
>>>>
>>>>and get any property using:
>>>>
>>>>oMyCalendar.AProperty
>>>>
>>>>Vlad
>>>>
>>>>>I created a form that uses the calendar control in VFP 5.0, and then saved this form as a class. As a form I can say "do form MyCalendar to dMydate" to get the value chosen. Can I get the value chosen if I use frmMyCal =createobject("MyCalendar")? I can't figure out how to use this as a class and get the value the user chose.
>>>>>
>>>>>Paul
Previous
Reply
Map
View

Click here to load this message in the networking platform