vb .net array loop?

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 14
Reputation: asif786 is an unknown quantity at this point 
Solved Threads: 0
asif786 asif786 is offline Offline
Newbie Poster

vb .net array loop?

 
0
  #1
Jan 1st, 2009
I am coding a program which will simulate a ballot box, where voting wil take place. The code generates a random number which is the voter number which is unique to each voter. This is output to the user before voting. I would like it to perform a check to see if the voter number has been used before or not. i will do this by asking the voter to input there voter number and then perform the check. Please help. Thanks a lot i know i have to use a loop to go through each number and see if it matches or not. But i dont know how to store the voter number as the program will have to be able to store anywhere between 2 and 5000.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: vb .net array loop?

 
0
  #2
Jan 1st, 2009
  1. ' /* Declare A New Stack Object */
  2. Dim usedIDs As New Stack
  3.  
  4. ' /* Assume User Enters VoterID In Textbox1 */
  5. if usedIDs.Contains(textbox1.text) then
  6. ' /* Voter Number Has Not Been Used Yet So... */
  7. ' /* Add Item To Stack */
  8. usedIDs.Push(textbox1.text)
  9. ' /* Keep Doing Stuff For Valid Voter ID */
  10. else
  11. messagebox.show("This Voter ID Is Already Used... Get Your Own!")
  12. end if
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: vb .net array loop?

 
0
  #3
Jan 2nd, 2009
Oops, I just realized that my code is wrong in the if statement. It should be:
  1. if usedIDs.Contains(textbox1.text) then
  2. ' /* ID Has Been Used! */
  3. messagebox.show("This Voter ID Is Already Used.... Get Your Own!")
  4. else
  5. usedIDs.Push(textbox1.text)
  6. end if
Sorry for that.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC