3 Replies - 14441 Views - Last Post: 17 March 2013 - 12:37 PM Rate Topic: -----

#1 burger1234  Icon User is offline

  • New D.I.C Head

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

While loops and arrays

Posted 17 March 2013 - 12:10 PM

Please help, I when i run this program, nothing shows. Thanks in advance.

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  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9383
  • View blog
  • Posts: 35,228
  • 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?
Was This Post Helpful? 1
  • +
  • -

#3 burger1234  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • 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...
Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • 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!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1