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

Possibly Related Threads…
Thread Author Replies Views Last Post
  More info about Random Access files PhilOfPerth 28 850 02-25-2026, 01:50 PM
Last Post: ahenry3068
  Maximum Number of Attachments per Thread Magdha 7 449 01-13-2026, 10:13 AM
Last Post: Magdha
  getting the number of dimensions in an array on the fly? madscijr 7 723 09-16-2025, 12:34 AM
Last Post: madscijr
  Out of range errors! Unseen Machine 4 546 08-17-2025, 04:11 AM
Last Post: Unseen Machine
  random maze map. math help pmackay 4 553 08-10-2025, 11:22 AM
Last Post: pmackay

Forum Jump:


Users browsing this thread: 1 Guest(s)