J
JamesL
I created one button and programmed it to a simple form change. I then
copied that button and pasted it several times. After this, I noticed that
in the code, VisualStudio had tied all of the buttons to the same click
event routine with each button listed sequentially in the handles.
The code as it appeared is:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmd1.Click, cmd2.Click, cmd3.Click, cmd4.Click
Dim frmTablet As frmTablet
frmTablet = New frmTablet
frmTablet.Text = cmd1.Text
frmTablet.Show()
End Sub
I want each of these buttons to open the same form, but I want the text from
the button to appear at the top of the form. I was going to call a
subroutine from the click event of each individual button and pass the text
property to the subroutine. But after seeing this I am wondering...
Can I leave all the buttons tied to the same Click event routine using the
handles as they appear here? And if so, how can I pass which button
triggered the event in order to select the correct text property? Is it as
simple as replacing cmd1.text above with Button1.text? Or do I need to
somehow add the button text property to the arguments in the routine?
If I can do this in this manner it would save a lot of code because I have
24 buttons to do this with.
James
copied that button and pasted it several times. After this, I noticed that
in the code, VisualStudio had tied all of the buttons to the same click
event routine with each button listed sequentially in the handles.
The code as it appeared is:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmd1.Click, cmd2.Click, cmd3.Click, cmd4.Click
Dim frmTablet As frmTablet
frmTablet = New frmTablet
frmTablet.Text = cmd1.Text
frmTablet.Show()
End Sub
I want each of these buttons to open the same form, but I want the text from
the button to appear at the top of the form. I was going to call a
subroutine from the click event of each individual button and pass the text
property to the subroutine. But after seeing this I am wondering...
Can I leave all the buttons tied to the same Click event routine using the
handles as they appear here? And if so, how can I pass which button
triggered the event in order to select the correct text property? Is it as
simple as replacing cmd1.text above with Button1.text? Or do I need to
somehow add the button text property to the arguments in the routine?
If I can do this in this manner it would save a lot of code because I have
24 buttons to do this with.
James