Integer Overflow in VBA project

Posted by mcoolbeth on Stack Overflow See other posts from Stack Overflow or by mcoolbeth
Published on 2010-04-19T16:39:05Z Indexed on 2010/04/19 16:43 UTC
Read the original article Hit count: 991

Filed under:
|
|

Hi, everyone. Here is a small VBA (Excel) function that i wrote, full of MsgBoxes for debugging.

I am passing in the numbers 10 and 1 as arguments, and getting an overflow error when the program reaches the top of the For loop, before it begins the first iteration.

Any thoughts are appreciated.

Function PerformanceTest(iterations As Integer, interval As Integer) As Double
    Dim st, tot, k As Double
    Dim n As Integer
    tot = 0#
    MsgBox "ok"
    k = iterations + tot
    MsgBox "ookk"
    n = 1
    MsgBox "assigned"
    For n = 1 To iterations
        MsgBox n
        st = Timer
        Application.Calculate
        tot = tot + (Timer - st)
        Sleep (1000 * interval)
    Next n
    'MsgBox (tot / k)
    PerformancTest = tot / k
End Function

© Stack Overflow or respective owner

Related posts about vba

Related posts about overflow