0

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.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Comatose
0
' /* Declare A New Stack Object */
Dim usedIDs As New Stack

' /* Assume User Enters VoterID In Textbox1 */
if usedIDs.Contains(textbox1.text) then 
     ' /* Voter Number Has Not Been Used Yet  So... */
     ' /* Add Item To Stack */
     usedIDs.Push(textbox1.text)
     ' /* Keep Doing Stuff For Valid Voter ID */
else
     messagebox.show("This Voter ID Is Already Used... Get Your Own!")
end if
0

Oops, I just realized that my code is wrong in the if statement. It should be:

if usedIDs.Contains(textbox1.text) then
     ' /* ID Has Been Used! */
     messagebox.show("This Voter ID Is Already Used.... Get Your Own!")
else
     usedIDs.Push(textbox1.text)
end if

Sorry for that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.