怎样使数组输出在text中,并且实现换行啊?
这是题目: 随机产生20个1~100的正整数放入数组中,显示产生的数,求最大值、最小值、平均值;
这是我写的代码:
Dim a(1 To 20) As Integer
Dim maxa As Integer, mina As Integer, avera As Integer
Private Sub Command1_Click()
For i = 1 To 20
a(i) = Int(Rnd * 100 + 1)
Next i
mina = a(1)
maxa = a(1)
avera = a(1)
For i = 2 To 20
If a(i) > maxa Then maxa = a(i)
If a(i) < mina Then mina = a(i)
avera = avera + a(i)
Next i
For i = 1 To 20
Text1.Text = Text1.Text & a(i) & " "
Next i
End Sub
Private Sub Form_Load()
Label1.Caption = "随机数"
Text1.Text = ""
Command1.Caption = "产生随机数’"
Text2.Text = ""
Command2.Caption = "结果"
End Sub
执行之后是这样的结果:
怎么能让里面的数字换行啊?? 谢谢了!!