[Gambas-user] Call control from one module
EA7DFH
ea7dfh at ...2382...
Thu May 13 00:29:20 CEST 2010
El 13/05/10 00:08, Jussi Lahtinen escribió:
> Project properties --> Check: Form controls are public.
>
> Jussi
>
>
> On Thu, May 13, 2010 at 00:45, craf <prog at ...2177...> wrote:
>> Hi.
>>
>> I need to call a control that is located on the main form from a module,
>> for this I have dealt with the following code:
>>
>> 'in module
>>
>> public sub proc_add()
>>
>> Fmain.control.text= "Hello"
>>
>> end sub
>>
>> But this form of call control does not work.
>>
>> Regards
>>
If you wont your controls to be public, use Properties instead.
(I think it is not a good idea to make public controls)
In your form:
PROPERTY myText as String
' then two functions will be created automagically:
PRIVATE SUB myText_Write(value as String)
textarea.Text = value
END
PRIVATE FUNCTION myText_Read() as String
RETURN textArea.Text
END
Then you could call your property from within a module or another class
MyForm.myText = whatevertext
'or
whatsmytext = MyForm.myText
Hope this helps
Jesus
More information about the User
mailing list