A sub to show which button has been clicked

mozaharul

Active Member
Licensed User
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.
 

taximania

Well-Known Member
Licensed User
Longtime User
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: 342
Last edited:
Top