> 数学 >
如何在VB6.0中生成10个20到50的随机数(保留两位小数)
人气:376 ℃ 时间:2020-06-15 07:15:57
解答
Private Sub Command1_Click()
Dim a(10) As Single
For i = 1 To 10
a(i) = Rnd * 31 + 10
Print Format(a(i),"0.00")
Next
End Sub怎么生成在文本框里呢?所有数字都生成在文本框?嗯,生成的随机数都要在文本框。Private Sub Command1_Click() Dim a(10) As Single dim temp as string temp="" For i = 1 To 10 a(i) = Rnd * 31 + 10 temp=temp & " " & Format(a(i), "0.00") Next Text1.Text=temp End Sub
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版