Using the "Mod" Function and this number "1000000000#" works but when I use the slightly longer number of "100000000000000" it doesn't and that is when I get returned that nasty Overflow Message.
Cheers
Printable View
Using the "Mod" Function and this number "1000000000#" works but when I use the slightly longer number of "100000000000000" it doesn't and that is when I get returned that nasty Overflow Message.
Cheers
#1 The number is being implicitly cast into a Long, which can hold a max of about 2 billion. That is causing the overflow.
#2 Why would you need to use a number that big?
gonna have to write your own sub, something like:
VB Code:
Private Sub Form_Load() answer = CDec(answer) Call LongMod(10000000000000#, 943, answer) MsgBox (answer) End Sub Sub LongMod(a, b, answer) a = CDec(a) b = CDec(b) c = CDec(a / b) d = Left(CStr(c), InStr(CStr(c), ".") - 1) answer = CDec(answer) answer = CDec(a) - CDec(d) * CDec(b) End Sub
I need a number that large for use in an algorithm.
I have used this function instead which works with numbers upto 19 digits long
VB Code:
Public Function funcMod(Number As Double, Divisor As Double) funcMod = Number - (Divisor * Int(Number / Divisor)) End Function
Cheers for your help