9 Loops with a 8 Row Array???

# Thread: 9 Loops with a 8 Row Array???

1. Senior Member
Join Date
Dec 1969
Posts
125

## 9 Loops with a 8 Row Array???

Why would the following 2d Array with 8 rows loop through 9 times?<BR><BR>Dim iMenu<BR><BR>For iMenu = 0 to UBound(MenuArray,2)<BR>With Response<BR> .Write strBlockStart<BR> .Write MenuArray(1, iMenu)<BR> .Write strBlockEnd<BR>End With<BR>Next

2. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

.

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Becuz it's a 9 row array.

How did you DIM it?<BR><BR>If you did<BR><BR>Dim MenuArray( 2, 8 )<BR><BR>then you got a 3 by 9 element array.<BR><BR>VBScript, unlike C/C++/Java/JavaScript has you specify the UPPER BOUND of the array dimension, *not* the number of elements.<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Give 2 aspirin for a broken bone?

Treat the symptom instead of the cause?<BR><BR>

5. Senior Member
Join Date
Dec 1969
Posts
125

## RE: I thought one defines...

I thought based on everything I have seen to this point that the "actual" number of rows is to be inserted into the definition when declaring an Array. I do understand what you mean Bill.<BR><BR>Thanks

6. Senior Member
Join Date
Dec 1969
Posts
125

## RE: Agreed! Works perfect now... Thanks

Thanks much

7. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Well he did not show us

the line where he create the array as far as i know....so....<BR><BR><BR><BR>i would have suggested 2 aspirinS and a drink of water though :p<BR><BR><BR>

8. Senior Member
Join Date
Dec 1969
Posts
96,118

## Thought right for most every language...

...*EXCEPT* VB and VBScript.<BR><BR>VBScript is derived from VB which is distantly derived from ANSI BASIC (a hokey standard of the early 1980&#039;s).<BR><BR>And that&#039;s how DIM has been specified in BASIC since at least that point in time.<BR><BR>(There is a reason, of sorts. Originally, DIM A(10) in BASIC gave you an array with elements numbered from 1 to 10. Then ANSI BASIC added an "OPTION BASE 0" statement to the language, which said that arrays started at zero. But to avoid (???) confusion, the upper bound remained the same. So from that day to this DIM A(10) has given the user 11 elements.<BR><BR>

#### Posting Permissions

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