Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I return a value from a class?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00060139
Message ID:
00060227
Vues:
25
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform