Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
generating a random number in the full range of that number? (Integer, Long)
#3
Thanks - it's amazing how simple that is. 

One thing that tripped me up was the INT function... 

I thought that was only for integer types, so I'd need to find the Long equivalent, so I tried CLNG, but no workie. 

I tried INT and it worked.

Code: (Select All)
Do
    Dim MyInt As Integer
    MyInt = Int(Rnd * 65536)
    Print "MyInt = Int(Rnd * 65536) = " + _ToStr$(MyInt)
    Input "Press Enter or Q to quit"; in$
    in$ = UCase$(Left$(_Trim$(in$), 1)): If in$ = "Q" Then Exit Do

    Dim MyLong As Long
    'MyLong = CLng(Rnd * 4294967295)
    MyLong = Int(Rnd * 4294967295)
    Print "MyLong = CLng(Rnd * 4294967295) = " + _ToStr$(MyLong)
    Input "Press Enter or Q to quit"; in$
    in$ = UCase$(Left$(_Trim$(in$), 1)): If in$ = "Q" Then Exit Do
Loop
System
Reply


Messages In This Thread
RE: generating a random number in the full range of that number? (Integer, Long) - by madscijr - 05-01-2025, 09:11 PM



Users browsing this thread: 1 Guest(s)