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

npnpAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Try this:
Dim SomeVar as Double
SomeVar = (y-1)*sizex*3 + 55
Get #ffile, SomeVar, a
0
 
mcriderCommented:
Once you define sizex try reclassing sizex...

For example:

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


Cheers!
0
 
É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
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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
0
 
Éric MoreauSenior .Net ConsultantCommented:
What is the value of sizex?

Can you show some real code that will surely cause the error.
0
 
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
    DoEvents
    Get #ffile, (y-1)*sizex*3 + 55, a
---etc---

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
0
 
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
0
 
AllenC_JrCommented:
Well npnp,

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

Dim A() As Byte
    'Declaration
Redim A(1 To 3, 1 To SizeX)
    'Redimention
'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,



-Linguar
0
 
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
0
All Courses

From novice to tech pro — start learning today.