# While loops and arrays

Page 1 of 1

## 3 Replies - 14964 Views - Last Post: 17 March 2013 - 12:37 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=315710&amp;s=67631d1f373c597d6d472e58f14022ee&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 burger1234

Reputation: 0
• Posts: 3
• Joined: 17-March 13

# While loops and arrays

Posted 17 March 2013 - 12:10 PM

```Dim whileIndex As Integer = 10
Dim arrNumbers(10) As Integer
Dim whileindex2 As Integer = 1
While arrNumbers(whileIndex) >= whileindex2
whileindex2 = 1
End While

'   A WHILE loop to output the contents of an array
While arrNumbers(whileIndex) >= whileindex2
arrNumbers(whileIndex) = arrNumbers(whileIndex) - 1
Console.WriteLine(whileindex2)

End While

```

Is This A Good Question/Topic? 0

## Replies To: While loops and arrays

### #2 modi123_1

• Suitor #2

Reputation: 13848
• Posts: 55,286
• Joined: 12-June 08

## Re: While loops and arrays

Posted 17 March 2013 - 12:16 PM

Put a breakpoint on line 9.. what is the value of "arrNumbers(whileIndex)"? My guess is zero.. since you created an array but never filled it with anything.. so when is 0 going to be greater or equal to 1?

### #3 burger1234

Reputation: 0
• Posts: 3
• Joined: 17-March 13

## Re: While loops and arrays

Posted 17 March 2013 - 12:30 PM

Thanks very much, you wouldn't believe how much time I spent trying to figure that out, you can probably tell that I'm a novice but you have to start somewhere I guess...

### #4 BobRodes

• Lovable Curmudgeon

Reputation: 600
• Posts: 3,069
• Joined: 19-May 09

## Re: While loops and arrays

Posted 17 March 2013 - 12:37 PM

I feel your pain. Learning about breakpoints and stepping through code one line at a time is going to save you a whole lot of grief. Well done!