Get overflow

y and sizex are computed, and both range from and including 1 to 512.

Dim a(1 to 3, 1 to sizex) as Byte
Get #1, (y-1)*sizex*3 + 55, a

If I DO NOT dimension sizex, there is no problem.  If I dimension sizex as Integer, the app stops at the get statement above, with "overflow" error.  What's going on here please? -- Norm

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.

Once you define sizex try reclassing sizex...

For example:

   Get #1,(y-1)*clng(sizex)*3+55,a

Éric MoreauSenior .Net ConsultantCommented:
You can't have a variable in the declaration of a variable!

So your line:
Dim a(1 to 3, 1 to sizex) as Byte

must become:
Dim a() as Byte
ReDim a(1 to 3, 1 to sizex) as Byte
npnpAuthor Commented:
emoreau: Yes, that's the way I have it. I mis-stated it in my original question.

mcrider: It is not clear to me exactly what is being overflowed. Presumably, its the receiving variable, "a" in this case.

Thank you both for your interest in this matter. I'll get back to you. -- Norm
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Éric MoreauSenior .Net ConsultantCommented:
What is the value of sizex?

Can you show some real code that will surely cause the error.
npnpAuthor Commented:
Here is the real code:

Dim y As Integer
Dim a() As Byte
Dim b(1 to 55) As Byte
' Dim sizex As Integer
' Dim sizey As Integer
Dim ffile As Integer
ffile = FreeFile
Open file for Binary As #ffile
  Get #ffile, 1, b ' HEADER
  sizex = b(19) + b(20) * 256
  sizey = b(23) + b(24) * 256
  ReDim a(1 To 3, 1 To sizex)
  For y = 1 to sizey
    Get #ffile, (y-1)*sizex*3 + 55, a

This runs fine.  However, if I uncomment Dim sizex and Dim sizey, the last code line is where the running program stops, with "overflow".

I appreciate your help. -- Norm
npnpAuthor Commented:
sizex and sizey run from 1 to 512.
Dim as byte therefore will not do.
I wish I had more points to give you.
-- Norm
Éric MoreauSenior .Net ConsultantCommented:
Try this:
Dim SomeVar as Double
SomeVar = (y-1)*sizex*3 + 55
Get #ffile, SomeVar, a

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial
Well npnp,

OK, I would suggest something like the following...

Dim A() As Byte
Redim A(1 To 3, 1 To SizeX)
'If you want to Find the sizes of the array positions(like 1 would represent the 1-3, 2 would represent 1-SizeX) you would use something like so...
SizeOfArrayPos = UBound(A(), 2) 'Return how large the array is in the second level of items.  Simple and straight forward.

Now since I am not 100% sure from your text on what you want, this is the best I can do...

Best Regards,

npnpAuthor Commented:
emoreau:  Thank you.  Dimensioning those two things as double seems to cure the "overflow" problem.  I'm still puzzled why that happens when they are dimensioned Integer, since integers go from -32768 to +32767, and my two variables go from 0 to 255.  (I think! - maybe I should check that out).

Happy new year! -- Norm
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.