Private Sub Command1_Click()
Dim a(10) As Long, b(5) As Long, i As Integer
For i = 1 To 10 輸入資料
a(i) = InputBox("請輸入第" & i & "個數", "整數輸入")
Next i
For i = 1 To 10 "顯示調換前的資料
Text1.Text = Text1.Text & vbCrLf & "a(" & i & ") =" & a(i)
For i = 1 To 5 "資料調換
b(i) = a(i)
a(i) = a(i + 5)
a(i + 5) = b(i)
For i = 1 To 10 "顯示調換後的資料
Text2.Text = Text2.Text & vbCrLf & "a(" & i & ") =" & a(i)
End Sub
Private Sub Command1_Click()
Dim a(10) As Long, b(5) As Long, i As Integer
For i = 1 To 10 輸入資料
a(i) = InputBox("請輸入第" & i & "個數", "整數輸入")
Next i
For i = 1 To 10 "顯示調換前的資料
Text1.Text = Text1.Text & vbCrLf & "a(" & i & ") =" & a(i)
Next i
For i = 1 To 5 "資料調換
b(i) = a(i)
a(i) = a(i + 5)
a(i + 5) = b(i)
Next i
For i = 1 To 10 "顯示調換後的資料
Text2.Text = Text2.Text & vbCrLf & "a(" & i & ") =" & a(i)
Next i
End Sub