Hi!!
Please help me, I have ha problem with multiply code.
I going to make several buttons on a form, but I want to minimize my code. I have tried using arrays but it doesn’t work with ‘New’ Se the following example. In the example I have five buttons, but in the real program I’m going to use 50 buttons. And that will generate lots of code if I can’t use arrays or something else.
So can any one help I would be grateful!!!
Dim button1 As New Button()
Dim button2 As New Button()
Dim button3 As New Button()
Dim button4 As New Button()
Dim button5 As New Button()
button1.Size = New Size(100, 100)
button2.Size = New Size(100, 100)
button3.Size = New Size(100, 100)
button4.Size = New Size(100, 100)
button5.Size = New Size(100, 100)
button1.Location = New Point(400, 200)
button2.Location = New Point(500, 200)
button3.Location = New Point(600, 200)
button4.Location = New Point(700, 200)
button5.Location = New Point(800, 200)
button1.Text = “Button1”
button2.Text = “Button2”
button3.Text = “Button3”
button4.Text = “Button4”
button5.Text = “Button5”
Form1.Controls.Add(button1)
Form1.Controls.Add(button2)
Form1.Controls.Add(button3)
Form1.Controls.Add(button4)
Form1.Controls.Add(button5)