Results 1 to 4 of 4

Thread: Well

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Well

    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

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    #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?
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    gonna have to write your own sub, something like:

    VB Code:
    1. Private Sub Form_Load()
    2.     answer = CDec(answer)
    3.     Call LongMod(10000000000000#, 943, answer)
    4.     MsgBox (answer)
    5. End Sub
    6.  
    7.  
    8. Sub LongMod(a, b, answer)
    9.     a = CDec(a)
    10.     b = CDec(b)
    11.     c = CDec(a / b)
    12.     d = Left(CStr(c), InStr(CStr(c), ".") - 1)
    13.     answer = CDec(answer)
    14.     answer = CDec(a) - CDec(d) * CDec(b)
    15. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2000
    Location
    Chesterfield, UK
    Posts
    298

    Well

    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:
    1. Public Function funcMod(Number As Double, Divisor As Double)
    2. funcMod = Number - (Divisor * Int(Number / Divisor))
    3. End Function

    Cheers for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width