943,832 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 3843
  • VB.NET RSS
Jan 1st, 2009
0

vb .net array loop?

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
asif786 is offline Offline
19 posts
since Dec 2008
Jan 1st, 2009
0

Re: vb .net array loop?

VB.NET Syntax (Toggle Plain Text)
  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
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 2nd, 2009
0

Re: vb .net array loop?

Oops, I just realized that my code is wrong in the if statement. It should be:
VB.NET Syntax (Toggle Plain Text)
  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.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Visual Basic 2008 and Access 2003 - Cant manage to search, can someone help ?
Next Thread in VB.NET Forum Timeline: custom openfile dialog box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC