我现在一般都用这个:
'获得随机数函数
Public Function Get_RandNum(fromNum,toNum)
If (fromNum<0) Or (toNum<0) Then
MsgBox "只接受大于零的输入"
ElseIf fromNum>toNum then
MsgBox "起始值必须小于结束值"
Else
Dim RunTime
Dim MyValue
Randomize(Timer)
MyValue =(int(rnd*(toNum - fromNum + 1)))+fromNum
Get_RandNum=MyValue
End If
End Function
'''''For m=0 to 9 这个函数是QTP自带的随机数字的产生
'''''i=RandomNumber(0,9)
'''''print i
'''''Next