1打开电脑桌面上的vb
2点击左面的textbox,在窗体中建造一个窗口,
3点击此窗口,修改command 1为通用,输入以下内容
Option Base 1
Private Sub Command 1_Click()
Cls
Dim n As Integer
Dim size As Integer
size = Int(Val(Me.Text1.Text))
Dim a() As Integer
ReDim a(size)
n = LBound(a)
While n <= UBound()
a(n) = Int(Rnd * 1000)
n = n + 1
Wend
Dim swap As Integer
m = LBound(a)
While m <= UBound(a) - 1
n = LBound(a)
While n <= UBound(a) - m
If a(n) <a(n + 1) Then
swap = a(n)
a(n) =a(n + 1)
a(n + 1) = swap
End If
n = n + 1
Wend
m = m + 1
Wend
n = LBound(a)
While n <= UBound(a)
Print a(n)
n = n + 1
Wend
End Sub
4点击运行即可看到结果
15电气郄慧敏15050341023