Solved

Multidimensional Array

Posted on 2004-08-13
10
193 Views
Last Modified: 2010-05-02
I have a multidimensional array that is 6 colums wide.

I am populating it from a recordset and therefore do not know the length so I using a dynamic array as below

currentfile = 0
WHILE NOT MyRS2.EOF
      IF currentfile = 0 Then
      ' do nothing
      Else
      Redim Preserve ArrPassed(5,currentfile)
      End IF
      ArrPassed(vantivenumber,currentfile) = MyRS("vantivenumber")
      ArrPassed(teamname,currentfile) = MyRS("teamname")
      ArrPassed(passedreason,currentfile) = MyRS("passedreason")
      ArrPassed(timetaken,currentfile) = MyRS("timetaken")
      ArrPassed(notes,currentfile) = MyRS("notes")
      ArrPassed(dateentered,currentfile) = MyRS("dateentered")
      currentfile = currentfile + 1
MyRS2.MoveNext
Wend

I am now trying to find out how to find out the ubound limits of the array so i can do a for next loop but i cant seem to figure it out from the many articles i have read.

This is extremely urgent hence the points.
0
Comment
Question by:JordansGhost
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +2
10 Comments
 
LVL 15

Expert Comment

by:Colosseo
ID: 11791548
Hi

have you tried UBound(ArrPassed)

That should work ok

Scott
0
 

Author Comment

by:JordansGhost
ID: 11791551
that returns 5 which is the 6 columns when 0 based, i need to know how many rows there is
0
 
LVL 15

Assisted Solution

by:Colosseo
Colosseo earned 50 total points
ID: 11791564
You could always switch your array around so your code snippet becomes

currentfile = 0
WHILE NOT MyRS2.EOF
     IF currentfile = 0 Then
     ' do nothing
     Else
     Redim Preserve ArrPassed(currentfile,5)
     End IF
     ArrPassed(currentfile,vantivenumber) = MyRS("vantivenumber")
     ArrPassed(currentfile,teamname) = MyRS("teamname")

and so on

Scott
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
mladenovicz earned 300 total points
ID: 11791571
UBound(arrayname[, dimension])

Ubound(ArrPassed,1)
Ubound(ArrPassed,2)


Example:

Dim A(1 To 100, 0 To 3, -3 To 4)


UBound(A, 1) ---> 100
UBound(A, 2) ---> 3
UBound(A, 3) ---> 4
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 11791573
Just realised that wont work with your preserve statement
0
 
LVL 15

Expert Comment

by:Colosseo
ID: 11791594
sorry, I meant my suggestion wont work... mladenovicz is spot on
0
 
LVL 18

Assisted Solution

by:JR2003
JR2003 earned 100 total points
ID: 11791657
to get the UBound of the 2nd dimension use the following:

UBound(ArrPassed, 2)

0
 
LVL 18

Expert Comment

by:JR2003
ID: 11791689
PS: You could dimension the array(Rows, Columns) rather than (Columns, Rows)
      then UBound without the dimension parameter would work.

UBound(arrayname[, dimension])

The UBound function syntax has these parts:

arrayname: Required. Name of the array variable; follows standard variable naming conventions.

dimension: Optional; Variant (Long). Whole number indicating which dimension's upper bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.
0
 
LVL 11

Assisted Solution

by:Sven
Sven earned 50 total points
ID: 11792042
You could also Dim the array to begin indexing at 1 not 0:

Dim array(1 To 10)
Dim multiarray(10, 1 To 10)
0
 

Author Comment

by:JordansGhost
ID: 11792319
Sorry guys, my mistake.

The problem was the recorset was EOF and this was the one time i didnt test for it. seen as the array didnt complain i presumed the data was in there.

All the information given was good and similar to what i have already read.

Ill split the points for your quick responses and grade accordingly.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question