problem determining the size of a 2 dimensional ar

# Thread: problem determining the size of a 2 dimensional ar

1. Senior Member
Join Date
Dec 1969
Posts
412

## problem determining the size of a 2 dimensional ar

I&#039;ve got this code in a component...<BR><BR>If Not jobRS.EOF Then<BR> jobOrders = jobRS.getRows()<BR>End If<BR><BR>If Not IsEmpty(jobOrders) Then<BR><BR>jobSize = UBound(jobOrders, 2)<BR><BR>I look in the table and run the query and it returns two records, but when I use this code, it&#039;s always returning one. So, I thought maybe I had to add 1 to the ubound(jobOrders,2) to get an accurate result. So, then I wrote this test page to see how that would work.<BR><BR>dim phoneArr(2,2)<BR>phoneArr(0,0) = "123-123-1234"<BR>phoneArr(0,1) = "home"<BR>phoneArr(1,0) = "123-123-1234"<BR>phoneArr(1,1) = "home"<BR>response.write ubound(phoneArr,2)<BR><BR><BR>This wrote out 2 as I expected. Can anyone explain why when I use getRows and the ubound of the results I get one less than is actually there? Thanks.

2. Senior Member
Join Date
Dec 1969
Posts
5,104

## RE: problem determining the size of a 2 dimensiona

Arrays are 0-based. So, when it returns a 1, there are actually 2 items in the array.<BR><BR>Do a for...next loop to display the contents, you will see that 2 records are displayed.<BR><BR>In your example, you are leaving the 3rd array location (#2) empty. The same code, Dim phoneArr(1,1) would allow you to store the same data as what you had.<BR><BR>-Doug

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•