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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getrows()

Status
Not open for further replies.

A1Pat

IS-IT--Management
Jun 7, 2004
454
US
hello all

I have problem understanding this part while acquiring a array in ASP

For i=0 to ubound(array,1)

The #1 after "array" is what I don't understand. Some tutorials said something about 2D if it was #2 and blah blah blah...

I need a simple explaination that just let know what will happen if it is 1 or 2 or whatever...

Thanks!
 
the number relates to the particular dimension of the array,

so if the dimensions are array(2,10);

ubound(array,1) will return 2
ubound(array,2) will return 10



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I'm sorry Chris :)

could you tell me more about dimensions.

and what if I don't declare any dimensions and I just have unbound(array,1).
 
When you declared the array, how did you declare it?
As a one-demensional array:
Code:
dim array(2)
or as a two-demensional array:
Code:
dim array(2,2)
?
 
ok, an array has at least one dimension ie;
dim array(n)
In this case ubound(array) and ubound(array,1) are the same, as the array only has a single dimension [array(0) ... array(n)]

For multi-dimensional arrays the number determines which dimension is returned, the default is 1 so omitting it will return the first dimension.
An array dimensioned as array(x,y,z) has three dimensions so can take parameters 1,2 or 3 for ubound(array,n) which equate to x,y or z.

objRS.GetRows() returns a two dimensional array in the form of array(columns,rows), but zero based (as all arrays are) so ubound(array,1) will return the number of columns -1 in the recordset and ubound(array,2) will return the number of rows -1 (recordcount) in the recordset.

The zero base is an important point to note because Recordsets are one based.



Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
with the dimentions it's easiest to think of it like a spread sheet, you're making a virtual spread sheet in memory, and specifying how many grid spots you want horizontally and vertically, if you go to third dimentions you're adding depth and so on..

so basically if you think of it as an excell spredsheet then the array(2,10) above would be columns A & B and rows 1-10 ( well not exactly but you get the idea i hope )

so in turn with getrows, you're returning that gridded out data set in array form, so if you need column 4 and row 13 you'd refer to it as myarray(3,12) ( notice the one lower numbers because your 1st position is actually 0 not 1 )

now ubound(array,2) is just to return the max of array in dimention 2 or dimention 1, just think of it as x and Y coordinates.. that might help :)


[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top