做一个文本框Text1,并设置其Multiline属性为True,再做一个Command1按钮,其代码如下:
Private Sub Command1_Click()
Dim a(9) As Integer, i As Integer, t As Integer
Text1.Text = ""
For i = 1 To 9
a(i) = i
Next i
Randomize
For i = 9 To 1 Step -1
t = Int(i * Rnd) + 1
Text1.Text = Text1.Text & a(t) & vbCrLf
a(t) = a(i)
Next i
End Sub