I am constructing an array in Vb .NET for a voting simulation program, i want it to store numbers which are being generated these will be unique numbers to each voter and then perform a check to see if the number input by the user matches those stored in the array.
The numbers generated are sequential i.e. 1,2,3 adding 1 each time here is my code;
Private Sub genrandomnum() counter = counter + 1 count = counter MsgBox("You're voter number is" & count) j = 5000 j = j - 1 j = k count = votearr(k) End Sub Private Sub btnvoternumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvoternumber.Click Call genrandomnum() End Sub Private Sub btnvoternum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvoternum.Click voternumcheck = InputBox("Please input voter number") booFound = False For k = 5000 To LBound(votearr) If voternumcheck = votearr(k) Then MsgBox("Value matched at k=" & k) Else MsgBox("Value was not found in array") End If Next k End Sub
As you can see i had a try but it does not work for some reason, thanks a lot