I think I've confused myself with this code !!!
I am creating Buttons down my Form that are incrementally numbered using the following code.
At the moment this is all I have, and the MessageBox will be replaced by real code, but the display always gives the last Button created, obviously, how can I ascertain which Button was pressed ?!?
Code:Private Sub Main_Screen() myRow = 0 myPosition = 87 While myDr.Read() myRow = myRow + 1 myBtn = "ProcessButton_" & myRow & "_1" myPosition = myPosition + 30 myPoint = New Point(12, myPosition) myWidth = 68 myHeight = 26 myName = "Process" CreateButton(myBtn) End While myDr.Close() mySQLcmd.Dispose() myConn.Close() End Sub Sub CreateButton(myButtonName) Dim myBtn As New Button myBtn.Location = myPoint myBtn.Width = myWidth myBtn.Height = myHeight myBtn.Text = myName myBtn.Name = myButtonName AddHandler myBtn.Click, AddressOf myBtn_Click Controls.Add(myBtn) End Sub Private Sub myBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) MessageBox.Show(myBtn & " is clicked.") End Sub




Reply With Quote
