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

Help with WHILE loops

Status
Not open for further replies.

mappryan

Structural
Joined
Mar 11, 2011
Messages
8
Location
US
I am very inexperienced with while loops. I am trying to write a loop that checks all the answers in a vector and if they are "OK" then it outputs "OK". I keep getting an "array index invalid for this array problem". I have written a simplified example of this problem to post here. If someone could please take a look and explain what I am doing wrong it would be greatly appreciated. I believe it is due to my lack of knowledge/experience with using a while loop altogether. Thank you
 
I don't see where you assign any value to "vec". If I make start and end different from each other the error goes away and veclocation has a value in the output (the value is the next cell after the end of the while).

David
 
well vec is not defined because I am using it as a function and therefore it isnt required to be defined. The origin has something to do with this problem as if i set the origin to zero in worksheet preferences both work. I think I have some sort of misunderstanding of the array indexing that I was hoping someone could clarify
 
No, it's due to the fact that your x cannot terminate your WHILE, resulting in the index going above 10. In fact, no vector with a 0 in the last location will terminate the WHILE.

TTFN

FAQ731-376
Chinese prisoner wins Nobel Peace Prize
 
IRstuff thank you. I realize what is wrong now. To fix it I am guessing there needs to be an otherwise statement added to the IF statement but I can't seem to get that to work. Any ideas of what i can do
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top