If you defined the buttons in the Designer for each button enter 'Buttons' in the EventName field and enter the number of the button in the Tag field.
If you defined the buttons in the code you must initialize them with
B4X:
Button1.Initialize("Buttons")
Button1.Tag = 1
Button2.Initialize("Buttons")
Button2.Tag = 2
' etc.
That means all buttons point to the same event routines.
Then you have to use the code below in the event routine:
B4X:
Sub Buttons_Click
Dim btn As Button ' defines a Button
btn = Sender 'sets btn to the Button that raised the event
Select btn.Tag ' btn.Tag is the Button number
Case 1
. ' code for Button1
Case 2
. ' code for Button2
Case n
.
End Select
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.