[Gambas-user] simplify code with picture
Jussi Lahtinen
jussi.lahtinen at gmail.com
Sun Nov 12 20:35:33 CET 2023
Simpler or faster? Anyway, I don't see much point on either. It is already
fast for GUI purposes and very simple.
However, here:
Button1.Picture = IIf(Button1.Picture = hLEDON, hLEDOFF, hLEDON)
Assuming you have the pictures declared this way:
Private hLEDON As Picture = Picture[ledON]
...
Jussi
On Sun, Nov 12, 2023 at 9:16 PM Fabien TONIUTTI <fabien.toniutti at free.fr>
wrote:
> Hello,
>
> I have one button with one picture who look like a LED on and off
>
> I have on boolean variable in my code named myvar.
>
>
> I could write this code :
>
> Public Sub button1_Click()
> myvar = Not myvar
> Select Case myvar
> Case False
> Button1.Picture = Picture[ledOFF]
> Case True
> Button1.Picture = Picture[ledON]
> End Select
> End
>
> Is existing on faster solution as this example bellow: (i didn't try it) :
>
> button1.Picture = myvar AND Picture[ledON]
>
> Thanks for your answer.
>
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231112/9c4974af/attachment.htm>
More information about the User
mailing list