窗体中放一个text控件,然后在里面输入数字,按回车,每输一个数,按一次回车
Dim i As Integer
Dim arr(10) As Long
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 13 Then Exit Sub
i = i + 1
Me.Caption = "输入第 " + CStr(i + 1) + " 个数"
If i < 10 Then
arr(i + 1) = Int(Text1.Text)
Else
i = 0
For x = 1 To 10
For y = 2 To x
If (arr(x) < arr(y)) Then
arr(0) = arr(x)
arr(x) = arr(y)
arr(y) = arr(0)
End If
Next
Next
Me.Caption = "输入第 " + CStr(i + 1) + " 个数"
Print "大到小:"
For m = 1 To 10
Print arr(m)
Next
End If
End Sub
温馨提示:内容为网友见解,仅供参考