Link to home
Start Free TrialLog in
Avatar of Ruffone
Ruffone

asked on

Arithmetic operation resulted in an overflow

Trying to create a random number with this line of code but it gives me this error. This is the number it creates "634732955157479720"

Private Shared randomNumGen As Random = New System.Random(CLng(DateTime.Now.Ticks - DateTime.Now.Millisecond))

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ruffone
Ruffone

ASKER

This fixed it for me

Private Shared random As New Random(CInt(DateTime.Now.Ticks And Integer.MaxValue))

Open in new window

Avatar of Ruffone

ASKER

Thanks