vb 随机数分组,挺麻烦的看好

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:52:07
要求挺多的看好
0 以command1激发inputbox
1 以inputbox("请输入个数")确定要产生的随机整数个数
2 在text1中将随机数组排列出来
3 在text2中将随机数组按一行5个排列,最后一行显示剩余随机数
4 在text3中将随机数组按一行3个排列,最后一行显示剩余随机数
5 以上随机数不能互相重复,再次按command1时清空所有text,并激发inputbox
-_-你觉得不麻烦那你做呗..
要不是我在网吧没VB就自己做了
思路大概是先MOD一下,求出落单的数的个数和整个的行数,然后就分下行就可以了.

谢谢你用我俩的组合~ 你既然能自己改了,我就懒得改答案了。

'text2和text3的multiline属性设为true,
'text2和text3的ScrollBars属性设为3
'text1的ScrollBars属性建议设为1
Private Sub Command1_Click()
Dim i As Double, j As Double, n As Double, temp As Double, a() As Double
Form_Load
n = Val(InputBox("个数:"))
ReDim a(n)

For i = 1 To n
AAA:
a(i) = Int(Rnd() * 100)
For j = 1 To i - 1
If a(i) = a(j) Then GoTo AAA
Next j, i

For i = 1 To n - 1
For j = i + 1 To n
If a(i) > a(j) Then
temp = a(i)
a(i) = a(j)
a(j) = temp
End If
Next j, i

For i = 1 To n
Text1.Text = Text1.Text & " " & Format(a(i), "00")
Text2.Text = Text2.Text & " " & Format(a(i), "00")
Text3.Text = Text3.Text & " " & Format(a(i), "00")
If i Mod 5 = 0 Then Text2.Text = Text2.Text & vbCrLf
If i Mod 3 = 0 Then Tex