Private Sub Form_Load()
ReDim iStr(1000) '存放數據
Dim i1 As Long
''錄入數據'''''''''''''''''''''''''''''''
'這里用隨機函數產生 你可以從數據文件讀取實際數據
For i1 = LBound(iStr) To UBound(iStr)
Randomize
iStr(i1) = Int(Rnd() * 50000)
Next i1
'''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Command1_Click()
Dim i1 As Long, i2 As Long
Dim s1 As String, s2 As String
Do
i1 = Rnd() * UBound(iStr)
Loop While i1 > UBound(iStr) - 5 '防止溢出
''''''''''''''''
For i2 = i1 To i1 + 5
s1 = s1 & i2 & "#-" & iStr(i2) & " "
Next i2
Label1 = "順序排列 " & s1
'''''''''''''''''
For i2 = i1 + 5 To i1 Step -1
s2 = s2 & i2 & "#-" & iStr(i2) & " "
Next i2
Label2 = "逆序排列 " & s2