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.

Recommended Answers

All 2 Replies

' /* 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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.