Dim my_pictureBox_kazu As Integer = 10 Dim my_pictureBox(my_pictureBox_kazu - 1) As PictureBox Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load my_pictureBox(0) = PictureBox1 my_pictureBox(1) = PictureBox2 my_pictureBox(2) = PictureBox3 my_pictureBox(3) = PictureBox4 my_pictureBox(4) = PictureBox5 my_pictureBox(5) = PictureBox6 my_pictureBox(6) = PictureBox7 my_pictureBox(7) = PictureBox8 my_pictureBox(8) = PictureBox9 my_pictureBox(9) = PictureBox10 For i As Integer = 0 To my_pictureBox_kazu - 1 my_pictureBox(i).BackColor = Color.Blue my_pictureBox(i).Size = New Size(10, 10) my_pictureBox(i).Location = New Point(30 + i * 20, 30) AddHandler my_pictureBox(i).Click, AddressOf my_pictureBox_click Next End Sub
Const my_pictureBox_kazu As Integer = 10 Dim my_pictureBox(my_pictureBox_kazu - 1) As PictureBox Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load For i As Integer = 0 To my_pictureBox_kazu - 1 Set my_pictureBox(i) = Me.Controls("PictureBox" & i) my_pictureBox(i).BackColor = Color.Blue my_pictureBox(i).Size = New Size(10, 10) my_pictureBox(i).Location = New Point(30 + i * 20, 30) AddHandler my_pictureBox(i).Click, AddressOf my_pictureBox_click Next End Sub