[Gambas-user] My first question how to access a public sub in another class???

Benoit Minisini gambas at ...2...
Sat Nov 1 17:50:50 CET 2003


Le Samedi 1 Novembre 2003 15:17, Olivier Coquet a écrit :
> hi all !
> for exemple:
>
> I have a form with a text label with "test" in text property
>
> i open a second form
>
> i want to change the text label text property of the first form from this
> second form.
>
> for instance i have made
>
> i have made a STATIC PUBLIC variable named texttest in my first form class
> (named firstform)
>
> and a PUBLIC SUB changelabel()
>
> I modify texttest static public variable in my second form (named
> secondform) i try to call :
> firstform.changelabel()
>
> but interpreter say me " changelabel() must be static" at runtime ?????
>
> if i make changelabel() as static, i can't acces any control property......
>
> a solution??????
>
> thanks in advance
> Olivier
>
>

Contrary to VB, forms are not self-instanciable. If the name of your form 
class is "MyForm", it doesn't mean that you have an instance of this form 
with the same name like in VB.

You must instanciate MyForm, and put the resulting reference in a global 
variable.

For example:

In MyForm:

STATIC PUBLIC Handle AS MyForm
...
Handle = NEW MyForm
...
MyDialog.Dialog
...
PUBLIC SUB ChangeLabel()
 ...
END

In MyDialog:
...
MyForm.Handle.ChangeLabel
...

Is it clearer ?

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the User mailing list