Dim TextBoxs() As TextBox = {TextBox1, TextBox2, TextBox3, TextBox4, TextBox5} 'コントロール配列
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For i As Integer = 1 To 5 Me.Controls("TextBox" & i).Text = "ここに入力" Next End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click For i As Integer = 1 To 5 Me.Controls("TextBox" & i).Text = String.Empty Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim sum As Integer For i As Integer = 1 To 5 sum += CInt(Me.Controls("TextBox" & i).Text) Next i TextBox6.Text = sum End Sub