Results 1 to 4 of 4

Thread: CInt overflow

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    8

    CInt overflow

    Give me CInt Overflow. What should I change to overcome this error
    Thanks ==================================================================================================== =================================
    ' function : GeneralVerify_SiteTenderAmts
    ' desc : Verifies that 2 arrays of tender types and their amounts have changed by the amount specified
    ' params : pArr1 - First array of tender types and amounts
    ' : pArr2 - Second array of tender types and amounts
    ' : pAmt - Amount that the amounts in the two arrays should differ by
    ' returns : N/A
    ' ==================================================================================================== =================================
    Sub GeneralVerify_SiteTenderAmts(pArr1, pArr2, pAmt)
    isPass = True
    If UBound(pArr1, 1) = UBound(pArr2, 1) and UBound(pArr1, 2) = UBound(pArr2, 2) Then
    For x = 0 to UBound(pArr1, 2)
    If CInt(pArr2(1,x)) - CInt(pArr1(1,x)) = pAmt Then strResults = strResults & "<tr><td>" & pArr1(0,x) & "</td><td bgcolor=#66FF66>$" & pArr1(1,x) & "</td><td bgcolor=#66FF66>$" & pArr2(1,x) & "</td><td bgcolor=#66FF66>$" & CInt(pArr2(1,x)) - CInt(pArr1(1,x)) & "</td></tr>"
    Else
    isPass = False
    strResults = strResults & "<tr><td>" & pArr1(0,x) & "</td><td bgcolor=#FF8080>$" & pArr1(1,x) & "</td><td bgcolor=#FF8080>$" & pArr2(1,x) & "</td><td bgcolor=#FF8080>$" & CInt(pArr2(1,x)) - CInt(pArr1(1,x)) & "</td></tr>"
    End If
    Next
    End If
    strTable = "Verify that the Tender Amounts in the SITE_TENDER table differ by $" & FormatCurrency(amt) & "<br/><table class=""tbFormat""><tbody><tr><th>Tender Type</th><th>Starting Amount</th><th>Ending Amount</th><th>Difference</th></tr>" & strResults & "</tbody></table>"
    If isPass = True Then
    Call Checkpoint_CustomReporter("Pass", "Verify SITE_TENDER", strTable)
    Else
    Call Checkpoint_CustomReporter("Fail", "Verify SITE_TENDER", strTable)
    End If
    End Sub

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: CInt overflow

    Please use [CODE]...[/CODE] tags when posting code.


    From Overflow article of VBScript Run-time Errors:



    Overflow

    The value you attempted to assign to a variable is too large. This error occurs when one of the following is true:

    • The result of an assignment, calculation, or data type conversion is too large to be represented within the range of values allowed for that type of variable.

    • An assignment to a property exceeds the maximum value the property can accept.

    • You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer.


    To correct this error

    • Assign the value to a variable of a type that can hold a larger range of values.

    • Make sure your assignment fits the range for the property to which it is made.




    Try using the CLng function instead of CInt.



    BTW, if you're satisfied with the answer, then you may now mark your thread Resolved.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    8

    Re: CInt overflow

    Thanks everyone
    Quote Originally Posted by Bonnie West View Post
    Please use [CODE]...[/CODE] tags when posting code.


    From Overflow article of VBScript Run-time Errors:



    Overflow

    The value you attempted to assign to a variable is too large. This error occurs when one of the following is true:

    • The result of an assignment, calculation, or data type conversion is too large to be represented within the range of values allowed for that type of variable.

    • An assignment to a property exceeds the maximum value the property can accept.

    • You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer.


    To correct this error

    • Assign the value to a variable of a type that can hold a larger range of values.

    • Make sure your assignment fits the range for the property to which it is made.




    Try using the CLng function instead of CInt.



    BTW, if you're satisfied with the answer, then you may now mark your thread Resolved.

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: CInt overflow

    No problem!

    Don't forget to mark this thread Resolved!
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

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