Lets modify the code a little:
Honestly, I've never played with that in .NETCode:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Integer For i = 1 To 10 Dim btn As New Button() Me.Controls.Add(btn) btn.Show() btn.Left = i * btn.Width btn.Name = "but" & i btn.Text = btn.Name Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim ctl As Control For Each ctl In Me.Controls If ctl.Name = "but1" Then MessageBox.Show("You got me!") Exit Sub End If Next MessageBox.Show("Did you click Button1?") End Sub![]()




Reply With Quote