Consulting

Results 1 to 4 of 4

Thread: VBA run time error 6 'overflow'

  1. #1
    VBAX Visitor
    Joined
    Mar 2011
    Posts
    0
    Location

    VBA run time error 6 'overflow'

    Hi Guys

    New to this board and hope you can help.

    I have an array which is declared as type long but when presented with variables a = 555 and b = 555555 the following multiplication cannot be performed.

    Dim Var as long

    Var = a * b

    I get a runtime error 6 'overflow' message.

    This is a simple example which I tried when my actual code did not work.

    Any help appreciated.

    Thanks

  2. #2
    VBAX Regular fmcti's Avatar
    Joined
    Mar 2011
    Posts
    16
    Location
    I have no problem with this code
    [VBA]
    Sub test()
    Dim a, b
    Dim var As Long
    a = 555
    b = 555555
    var = a * b
    MsgBox var
    End Sub
    [/VBA]

  3. #3
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    Likewise. Can you post your sampe that fails?

    [VBA]
    Option Explicit
    Sub test()
    Dim ary(0 To 2) As Long

    ary(0) = 555
    ary(1) = 555555
    ary(2) = ary(0) * ary(1)

    MsgBox ary(2)

    End Sub
    [/VBA]

    Paul

  4. #4
    VBAX Newbie
    Joined
    May 2012
    Posts
    1
    Location
    Dear no problem with this code Sub test()
    Dim a, b
    Dim var As Long
    a = 555
    b = 555555
    var = a * b
    MsgBox var
    End Sub

Posting Permissions

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