PDA

View Full Version : VBA run time error 6 'overflow'



laxcb
03-01-2011, 12:57 PM
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

fmcti
03-29-2011, 04:57 AM
I have 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

Paul_Hossler
04-01-2011, 06:09 PM
Likewise. Can you post your sampe that fails?


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


Paul

asifkhan
05-25-2012, 07:47 AM
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