[Gambas-user] Changing the value of a variable or object outside the class
Mayost Sharon
sharon at 455.co.il
Mon Apr 17 07:41:30 CEST 2023
---------- Original Message -----------
From: BB <adamnt42 at gmail.com>
To: user at lists.gambas-basic.org
Sent: Mon, 17 Apr 2023 12:23:41 +0930
Subject: Re: [Gambas-user] Changing the value of a variable or object outside the class
> On 17/4/23 12:17 am, Mayost Sharon wrote:
> > Hello, I hope the title is correct
> >
> > Further to the discussion:
> > https://lists.gambas-basic.org/pipermail/user/2023-April/079118.html
> > which ended successfully
> >
> > I have a new question related to classes
> >
> > I am trying to change a property of an object that is in class1 but I am inside class2
> >
> > Attached is the code I am trying and it does not allow access from class2 to class1
> >
> > Class 1 has an h_timer object
> > I want in class 2 to change the value of h_timer.Delay
> >
> > Thanks
> >
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> Create a Public Sub in Class 1 thus
>
> Public Sub SetDelay(newDelay as Integer)
> h_timer.Delay = newDelay
> End
>
> Then you can somehow call the method on the Class1 _object_ from any
> Class2 object.
>
> I too am unsure it is that you are really trying to achieve here. Your
> questions seem quite illogical.
>
> b
------- End of Original Message -------
Thank you
I checked it doesn't work
It seems that as T Lee Davidson said a STATIC statement should be added
With a timer, you're right that it doesn't make sense
But let's say it will be h_connection
that you open it once in CLASS1
And in the rest of the CLASSS you want to perform operations on the h_connction
such as inserting a record, deleting a record, etc.
And I want to do it through CLASS2 or CLASS3
More information about the User
mailing list