M
mirkolara
Guest
Hello to all, i am new in b4a and i'm stuck in something maybe very stupid.
I' have created 2 buttons (with images) using the Designer and added the members:
I created a sub that does a bunch of things once Button1 is clicked, i want to use the same sub for all 2 buttons i've created without duplicate it.
I want to do this because i need to change the value of some variables before execute my function depending of which button is clicked and i don't want to duplicate the sub for every button (which will be over 30)
I tried something like this but no luck:
Thank you.
I' have created 2 buttons (with images) using the Designer and added the members:
B4X:
Sub Globals
Dim Button1 As Button
Dim Button2 As Button
End Sub
I want to do this because i need to change the value of some variables before execute my function depending of which button is clicked and i don't want to duplicate the sub for every button (which will be over 30)
I tried something like this but no luck:
B4X:
Button1.Initialize("mysub")
Button1.Tag = 1
Button2.Initialize("mysub")
Button2.Tag = 2
Dim btn As Button
btn = Sender 'Cast the Object to Button
Select btn.Tag
Case 1
' Set my vars..
Case 2
' Set my vars..
End Select
Sub mysub_click '<-- I want to use it for all buttons, but passing different values to my vars and without duplicate it.
'do things.
End Sub
Thank you.
Last edited by a moderator: