我编写了一个程序
Dim flag As Integer
Dim m(1 To 100) As Integer
Dim i As Integer
Dim p As Integer
Function f(i) As Integer
For p = 1 To i - 1
If m(i) = m(p) Then m(i) = (Int(Rnd() * c) + b): flag = 1
If m(i) <> m(p) Then flag = 0
Next p
If flag = 0 Then Print (m(i))
If flag = 1 Then f (i)
End Function
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
Dim j As Integer
Randomize
a = InputBox("您想产生几个随机数呢?")
b = InputBox("随机数范围的起点是多少呢?(能取到)")
c = InputBox("随机数范围的终点是多少呢?(能取到)")
For i = 1 To a
flag = 0
m(i) = (Int(Rnd() * c) + b)
f (i)
Next i
End Sub
我试图用这个程序来求随机数,但有时会跳出“溢出”提示,而且随机数也不对(比如从1开始随机时会出现0),请高手指教会给出另外的类似程序