M mozaharul Active Member Licensed User Dec 19, 2010 #1 Hi, I'm trying to write a sub programm which shows a message that a specific button has been clicked out of a number of buttons. the sub programm: sub which_button_clicked x = control("Button" & ??? ).name msgbox(x) end sub ??? = what should be there then : sub Button1_click which_button_clicked end sub sub Button2_click which_button_clicked end sub sub Button3_click which_button_clicked end sub best regards.
Hi, I'm trying to write a sub programm which shows a message that a specific button has been clicked out of a number of buttons. the sub programm: sub which_button_clicked x = control("Button" & ??? ).name msgbox(x) end sub ??? = what should be there then : sub Button1_click which_button_clicked end sub sub Button2_click which_button_clicked end sub sub Button3_click which_button_clicked end sub best regards.
Erel B4X founder Staff member Licensed User Longtime User Dec 19, 2010 #2 You should use the Sender keyword. See this tutorial: http://www.b4x.com/forum/tutorials/907-runtime-controls-manipulation.html
You should use the Sender keyword. See this tutorial: http://www.b4x.com/forum/tutorials/907-runtime-controls-manipulation.html
taximania Well-Known Member Licensed User Longtime User Dec 19, 2010 #3 Number your buttons from 1 to 'x', however many you have. Add the Button_Click event at runtime. Sub App_Start Form1.Show For a = 1 To 'x' AddEvent("Button" & a,Click, "Btn1_Click") Next a End Sub Sub Btn1_Click a=Sender.text msgbox(a) End sub Attachments click example.sbp 893 bytes · Views: 368 Last edited: Dec 19, 2010
Number your buttons from 1 to 'x', however many you have. Add the Button_Click event at runtime. Sub App_Start Form1.Show For a = 1 To 'x' AddEvent("Button" & a,Click, "Btn1_Click") Next a End Sub Sub Btn1_Click a=Sender.text msgbox(a) End sub