设计一个程序。在上面框中产生任意100个数,将其中>=50的数排序后放到下面的框中。

来源:百度知道 编辑:UC知道 时间:2024/07/07 22:36:32
上面框(可以是文本框、标签、图片和图像) 两个框各自对应各自的按钮

帮帮忙
谢谢

Rem 文本框均在属性窗口设置MultiLine=True,ScrollBars=2

Dim num50 As String

Private Sub Command1_Click()
Dim i As Integer, temp As Integer
Randomize
Text1 = ""
num50 = ""
For i = 1 To 100
temp = Int(100 * Rnd)
Text1 = Text1 & Format(temp, "@@@")
If i Mod 10 = 0 Then Text1 = Text1 & vbCrLf
If temp >= 50 Then num50 = num50 & " " & temp
Next i

Command2.Enabled = True
End Sub

Private Sub Command2_Click()
Dim t, n As Integer, a() As Integer

num50 = Trim(num50)
If num50 = "" Then Exit Sub
t = Split(num50, " ")
ReDim a(1 To UBound(t) + 1)
For i = 0 To UBound(t)
a(i + 1) = Val(t(i))
Next

For i = LBound(a) To UBound(a) - 1
For j = i + 1 To UBound(a)
If a(i) < a(j) Then
t = a(i): a(i) = a(j): a(j) = t
End If
Next j
Next i

Text2 = ""