Sunday, May 8, 2011

Programmatic adding of elements

 This code will create a times table..

  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
     For x = 1 To 10
  
       For y = 1 To 10
  
         Dim button1 As New Button
  
         button1.Location = New Point(40 * x, 40 * y)
  
         button1.Width = 40
  
         Me.Controls.Add(button1)
  
         button1.Text = x * y
  
       Next
  
     Next
  
   End Sub  

No comments:

Post a Comment