随机在列表中产生5组三个相邻的正整数N,N+1,N+2,N大于等于100小于1000, 求vb代码,谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/31 17:49:06

实际上,每组只随机一个中间的数,,两边的+1-1就出来了;
五组,循环5次就行!

Private Sub Command1_Click()
For i = 1 To 5
x = Int(Rnd * (999 - 101) + 101)
Print x - 1, x, x + 1
Next i
End Sub

我用了15个text,有点晕乎

Private Sub Command1_Click()
Text1(0).Text = Int((1000 - 100) * Rnd + 100)
Text1(1).Text = Text1(0).Text + 1
Text1(2).Text = Text1(1).Text + 1
Text1(3).Text = Int((1000 - 100) * Rnd + 100)
Text1(4).Text = Text1(3).Text + 1
Text1(5).Text = Text1(4).Text + 1
Text1(6).Text = Int((1000 - 100) * Rnd + 100)
Text1(7).Text = Text1(6).Text + 1
Text1(8).Text = Text1(7).Text + 1
Text1(9).Text = Int((1000 - 100) * Rnd + 100)
Text1(10).Text = Text1(9).Text + 1
Text1(11).Text = Text1(10).Text + 1
Text1(12).Text = Int((1000 - 100) * Rnd + 100)
Text1(13).Text = Text1(12).Text + 1
Text1(14).Text = Text1(13).Text + 1
End Sub