Hi Dan,
>How do I return a value from a visual class. I have created a class based on a form. The form is Modal. In the Unload event of the form I placed return This.cRetVal.
>
>In the calling program, I have:
>
>oObject = createobject("MyObject")
>cRetVal = oObject.Show()
>
>cRetVal is always .F. when returning.
>
>What am I doing wrong?
You cannot return a value from .vcx based modal forms(without a little trick). The Form.Unload is ignored for .vcx based forms.
You can create a wrapper program that declares a private memvar and then calls the form. The memvar is available to the form and can be set in the Unload event.
Make a wrapper program;
procedure wrapper
lparameter myobject
private tuReturnValue
tuReturnValue = .null.
oObject = createobject("MyObject")
oObject.Show(1)
return tuReturnValue
In the Unload of the modal form do this;
tuReturnValue = This.cRetVal
Then you would issue something like this;
x = wrapper("myobject")
hth,
Kendall Webb
Senior Software Engineer
MCAD.Net/MCSD.Net