vb语言如何产生随机数组并使数组在text中显示

text可以多行显示
2024-11-26 16:31:12
推荐回答(2个)
回答(1):

产生100个1000以内随机数并在Text中显示
Private Sub Form_Load()
Dim a(100) As Integer
Randomize Timer
For k = 1 To 100
a(k) = Int(Rnd() * 1000)
Text1 = Text1 & Str(a(k))
Next k
End Sub

回答(2):

Option Explicit

Private Sub Command1_Click()
Dim a(3) As Single
Dim i As Integer
Randomize
For i = 0 To 3
a(i) = Rnd()
Text1.Text = Text1.Text & a(i) & vbCrlf
Next
End Sub