P
Paul Mars
I am creating a user selectable quantity of buttons at run time and need to
respond to their click events. My code:
Dim btnButton as Button (global)
Then in a sub:
For intNumBtnsDown = 0 To intNumBtns - 1
pointLocate.Y += 70
pointLocate.X = 0
For intNumBtnsAcross = 0 To intNumBtns - 1
pointLocate.X += 70
btnButton = New Button
With btnButton
..Name = "btn" & CStr(intNumBtnsDown) & CStr(intNumBtnsAcross)
....
End With
pnlBtns.Controls.Add(btnButton)
AddHandler btnButton.Click, AddressOf GameBtns
Problem is that GameBtns thinks that each button created has the same name
which is the name of the last button created. Teacher says need to Dim the
button with the individual names, as ""btn" & CStr(intNumBtnsDown) &
CStr(intNumBtnsAcross)"", then replace the addhandler event with the same.
He does not remember how to do this, is busy and he challenged me to figure
it out. He said that I could use the internet and when I asked, he said that
I could use ngs. Help please.
respond to their click events. My code:
Dim btnButton as Button (global)
Then in a sub:
For intNumBtnsDown = 0 To intNumBtns - 1
pointLocate.Y += 70
pointLocate.X = 0
For intNumBtnsAcross = 0 To intNumBtns - 1
pointLocate.X += 70
btnButton = New Button
With btnButton
..Name = "btn" & CStr(intNumBtnsDown) & CStr(intNumBtnsAcross)
....
End With
pnlBtns.Controls.Add(btnButton)
AddHandler btnButton.Click, AddressOf GameBtns
Problem is that GameBtns thinks that each button created has the same name
which is the name of the last button created. Teacher says need to Dim the
button with the individual names, as ""btn" & CStr(intNumBtnsDown) &
CStr(intNumBtnsAcross)"", then replace the addhandler event with the same.
He does not remember how to do this, is busy and he challenged me to figure
it out. He said that I could use the internet and when I asked, he said that
I could use ngs. Help please.