Question : voting system in vb.net 2008 without database

say i have 5 radio buttons and a vote button if you click on any radio and then vote it will remember the count for that radio button. then at the end i want to be able to compare to see which one has the most vote. what's the best way to do it?

Answer : voting system in vb.net 2008 without database

Sorry I didn't finish typing in previous post:


You need to maintain a string or a list or something as you go do checking for a tie.
If at any time a Tie is broken by another box, you need to reset the string.
Its more code...

to check and display results you can do this :

dim chkWinner  as new checkbox
dim WinnerMessage as String
dim bTie as boolean
bTie = false
if  Val(checkbox1.tag) < Val(checkbox2.tag)  then
      WinnerMessage  = checkbox2.text
       chkWinner   = checkbox2
       bTie = false
elseif( Val(checkbox1.tag) = Val(checkbox2.tag) ) then
      WinnerMessage += "," + checkbox1.text
       chkWinner   = checkbox1
      bTie = true
else
        WinnerMessage  = checkbox1.text
          chkWinner   = checkbox1
          bTie = false
end if

if Val(chkWinner.tag) < Val(checkbox3.tag)  then
       WinnerMessage  = checkbox3.text
       chkWinner   = checkbox3
       bTie = false
elseif Val(chkWinner.tag)= Val(checkbox3.tag)  then
      WinnerMessage += "," + checkbox3.text
      bTie = true
end if
if Val(chkWinner.tag) < Val(checkbox4.tag)  then
   WinnerMessage  = checkbox4.text
   chkWinner   = checkbox4
   bTie=false
elseif Val(chkWinner.tag) = Val(checkbox4.tag)  then
      WinnerMessage += "," + checkbox4.text
      bTie = true
end if
[... and so on]

if bTie = false then
    msgbox("the winner is  : " & chkWinner.text & " with " &  chkWinner.tag & " votes")
else
   msgbox("We have a tie between : " & WinnerMessage & " with " & chkWinner.tag & " votes")
end if

Random Solutions  
 
programming4us programming4us