Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Processing

Status
Not open for further replies.

TOMBUGGY

Programmer
Oct 4, 2000
36
0
0
US
I have a 2-dimensional array that can have a variable number of rows and columns. Depending on user input it could be 6x6 (36 elements), 6x12 (72 elements), 16x16 (256 elements), etc.

Can someone provide EFFICIENT code for accessing all the elements in row sequence - that is, all the elements in Row 1, then all the elements in Row 2, etc.? Thanks.
 
When you say accessing the elements, do you just mean reading them?
Code:
For R& = 1 To UBound(MyArray(1))
  For C& = 1 To UBound(MyArray(2))
    ' Do something with MyArray(R&, C&)
Next C&, R&

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Thanks Andy. To answer your question, I want to "do something" as I access each element.
 
OK well I guess the code I posted should do the trick.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Andy, not working. The array I'm using is named ddbets and it's dimensioned as ddbets(RR1%, RR2%). I get a Compile Error - Expected Array on the statement:

For R& = 1 to Ubound(ddbets(1))
 
Sorry. Head's a shed.
Code:
For R& = 1 To UBound(MyArray, 1)
  For C& = 1 To UBound(MyArray, 2)
    ' Do something with MyArray(R&, C&)
Next C&, R&

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Andy, thanks again. I consulted a manual and found the correct statement content.
 
A programmer who consults the manual? Dying breed.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top