[Gambas-user] simplify code with picture

vuott at tutanota.com vuott at tutanota.com
Mon Nov 13 19:12:39 CET 2023


...by using a "ToggeButton" I'ld also suggest:

[code]
Public Sub ToggleButton1_Click()

  PictureBox1.Picture = Picture[ledOFF]
  If ToggleButton1.Value Then PictureBox1.Picture = Picture[ledON]

End
[/code]



13 nov 2023, 16:29 da t.lee.davidson at gmail.com:

> On 11/12/23 14:35, Jussi Lahtinen wrote:
>
>> 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
>>
>
>
> Yes.
>
> Or, do away with the 'myvar' semaphore and simply use a ToggleButton:
> ToggleButton1.Picture = IIf(ToggleButton1.Value, hLEDON, hLEDOFF)
>
>
> -- 
> Lee
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231113/2746f24b/attachment-0001.htm>


More information about the User mailing list