第1个回答 2014-05-24
先把Text1的MultiLine属性设为True,这样文本框才能进行换行
Private Sub Command1_Click()
Text1 = "" '清空Text1中的现有文本
Dim score(1 To 20) As Integer, i As Integer, j As Integer
For i = 1 To 20 '用随机函数给数组score()赋100以内的值
score(i) = Int(Rnd * 100)
Next i
For i = 20 To 2 Step -1 '用冒泡排序法对已赋值的数组进行排序
For j = 1 To i - 1
If score(j) > score(j + 1) Then
t = score(j)
score(j) = score(j + 1)
score(j + 1) = t
End If
Next j
Next i
For i = 1 To 20 '在文本框中输出排好序的数组
Text1.Text = Text1.Text & Space(3) & score(i)
If i Mod 5 = 0 Then '输出五后个换行
Text1.Text = Text1.Text & Chr(13) + Chr(10)
End If
Next i
End Sub本回答被提问者采纳