My Loop Wont Loop Properly.

Page 1 of 1

1 Replies - 204 Views - Last Post: 09 October 2012 - 01:25 PM Rate Topic: -----

#1 CodyMcCoderson  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 08-October 12

My Loop Wont Loop Properly.

Posted 09 October 2012 - 01:24 PM

I have created a nested loop which I believe is the proper way to do what I am doing.
The problem im having is when it asks the first candidates name, it then asks the amount of votes 5 times.
IN SHORT
Suppose to read:
Please enter name of candidate 1
Please enter votes for candidate 1
Please enter name of candidate 2
Please enter votes for candidate 2

Reads like:
Please enter name of candidate 1
Please enter votes for candidate 1
Please enter votes for candidate 2
Please enter votes for candidate 3

[code]
Public Sub candidateArray()
Dim nameArray(4) As String
Dim voteArray(4) As Integer

For nameCounter = 0 To 4
Console.WriteLine("Please enter candidate #" & nameCounter + 1)
nameArray(nameCounter) = Console.ReadLine()

For voteCounter = 0 To 4
Console.WriteLine("Please enter the number of votes for candidate #" & voteCounter + 1)
voteArray(voteCounter) = Console.ReadLine()

Console.WriteLine()
Next
Next
End sub

Delete This, created by accident.

Thanks

DELETE THIS, CREATED BY ACCIDENT

Is This A Good Question/Topic? 0
  • +

Replies To: My Loop Wont Loop Properly.

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8909
  • View blog
  • Posts: 33,398
  • Joined: 12-June 08

Re: My Loop Wont Loop Properly.

Posted 09 October 2012 - 01:25 PM

Please do not create duplicate topics.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1