# (50 pts) Error 6 - Overflow

I'm designing a program that will calculate the number of Miliseconds in a Millenium and everything in between.  As  you can tell, I need a way to store and work with VERY large numbers.  I tried using Double and it's giving the a Run-Time Error 6 - Overflow.  That shouldn't be happening especially since it gives it trying to store the value 60,000.  Here's my code.  PLEASE HELP !!

Public zConst_Time(12, 12) As Double

zConst_Time(3, 1) = 1000 * 60

It gives the error on this line.  What's going wrong?

HATCHET
LVL 3
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
60 and 1000 are *integers*.

Write:

zConst_Time(3, 1) = 1000.0 * 60.0

and it will work.

m
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
mark2150,

Thanks for the help!  Your answer didn't work EXACTLY... but got me where I needed to go.  Visual Basic saw the extra ".0" at the end of the numbers and changed them to pound signs ( # ).

For some reason... if you put a pound sign, which is the Double data type indicator, at the end of the first number to be multiplied, it works.  I assume that once it hits that first pound sign it knows the rest of the values are Double as well.  Like this:

zConst_Time(1, 1) = 1000# * 60 * 60 * 24 * 7 * 4.345 * 3 * 4 * 1000

That returns the following value : 31534272000000

Thanks again !

HATCHET
0
Commented:
Vb is easy going about data types. It looks at the types on the right side of the assignment and computes the result in the "lowest" (shortest?) data type that all of the values have. Since all the values were INTEGERS it did integer math and 60000 is out of the integer range of +-32767 and *bang* you're dead. It didn't matter that the zConst_Time() array was defined as DOUBLE because the overflow occurred in an intermediate value as it was evaluating the right side of the assignment.

As long as *any* of the values on the right is non-integer it should work. The # sign is appended because .0 is technically "redundent", but it figured out that you wanted a *real* there instead of an integer and used the # to force the type. You could eliminate it in your example since you have 4.345 as one real in the series. This will force the intermediate result to a real and all is fine.

This is both a strength and weakness of VB. It allows you to write without worrying about typing, but occassionally, it rears it's head and *bites* you.

M
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.