• Welcome to Valhalla Legends Archive.
 

Creating a Vote Feature

Started by OuTLawZGoSu, January 17, 2004, 12:20 PM

Previous topic - Next topic

o.OV

#15
I am not keen on using gui based items..
but I would like to help..

(*closes eyes*)
Here is untested code:


'If VotingBooth returns 1 it means no action was made _
   and to continue other message checks.
Public Function VotingBooth(UserName As String, Message As String) As Long
   Dim voteMessage As String
   voteMessage = LCase$(Message)
   If Form1.chkvote Then
       'I assume LoadMaster and LoadTrigger is a Public/Global variable.
       If UserName = LoadMaster And voteMessage = "voff" Then
           Form1.chkvote = vbUnchecked
           AddQueue "Results: " & Form1.lbyes.ListCount & " voted for Yes, " & Form1.lbno.ListCount & " voted for No."
           Form1.lbyes.Clear
           Form1.lbno.Clear
       ElseIf voteMessage = "yes" Then
           vList Form1.lbyes, UserName
       ElseIf voteMessage = "no" Then
           vList Form1.lbno, UserName
       Else
           VotingBooth = 1
       End If
   ElseIf UserName = LoadMaster And Left$(voteMessage, Len(LoadTrigger) + 5) = LoadTrigger & "vote " Then
       Form1.chkvote = vbChecked
       AddQueue "Vote: " & Mid(Message, 6, Len(Message) - 1)
   Else
       VotingBooth = 1
   End If
End Function
Public Sub vList(vListToUse As ListBox, UserName As String)
   If Form1.lbno.ListCount > 0 Then
       For X = 0 To Form1.lbno.ListCount - 1
           If UserName = Form1.lbno.List(X) Then Exit Sub
       Next X
   End If
   If Form1.lbyes.ListCount > 0 Then
       For X = 0 To Form1.lbyes.ListCount - 1
           If UserName = Form1.lbyes.List(X) Then Exit Sub
       Next X
   End If
   vListToUse.AddItem UserName
End Sub


In Outlaw's code.. What is FindItem(X) and what is X ?
I have no clue how that works...

And what is a ListView never seen one of those before unless its the same thing as as ListBox. (Example above uses ListBox)
If the facts don't fit the theory, change the facts. - Albert Einstein

hismajesty

Ah, I misunderstood the post. I was thinking he was using a listview/box for storing the votes.

Arta

I believe he was trying to say:


If username_you_got = username_you_want Then ...

ChR0NiC

The
If Username = Username Then
is basically saying........no matter what, the vote counts......but I just hope he knows he doesn't need to do that.....hehehehe

ChR0NiC

#19
Quote from: o.OV on January 21, 2004, 08:09 PM

In Outlaw's code.. What is FindItem(X) and what is X ?
I have no clue how that works...


When using (X) it is searching the "index" for the integer that X is declared as. Such as FindItem(2) would be the 2nd item from the top....but using X would allow him to search every row instead of just one...
Bah......I am so bad at explaining things....I hope you understand >.<

But you are right.....he doesn't seem to declare X as anything, so it is no wonder you would be confused about it