I got this:
I need to add theusername to the list when "Yes" or "No" is typed.
Exept, when the user types yes or no, nothing happens.
'Vote
'
If username = LoadMaster Then
If Left((LCase(message)), 5) = (LoadTrigger & "vote") Then
Form1.chkVote = vbChecked
AddQueue "Vote: " & (Mid(message, 6, Len(message) - 1))
End If
End If
If username = username And LCase(message) = "yes" Then
If username = Form1.voteuserchk.FindItem(x) Then
If Form1.chkVote = vbChecked Then Form1.LbYes.AddItem "Yes"
End If
Form1.voteuserchk.ListItems.add 1, , username
End If
If username = username And LCase(message) = "no" Then
If username = Form1.voteuserchk.FindItem(x) Then
If Form1.chkVote = vbChecked Then Form1.LbNo.AddItem "No"
End If
Form1.voteuserchk.ListItems.add 1, , username
End If
If username = LoadMaster And LCase(message) = "voff" Then
If Form1.chkVote = vbChecked Then
Form1.chkVote = vbUnchecked
Form1.txtYes = Form1.LbYes.ListCount
Form1.txtNo = Form1.LbNo.ListCount
AddQueue "Results: " & Form1.txtYes.text & " voted for Yes, " & Form1.txtNo.text & " voted for No."
Form1.LbYes.Clear
Form1.LbNo.Clear
Form1.txtYes.text = ""
Form1.txtNo.text = ""
Form1.voteuserchk.ListItems.Clear
End If
End If
Help?
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
Quote from: UserLoser. on January 17, 2004, 02:59 PM
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
That just means If any user type in Yes or No then.
If you're going to let anybody use it why have an if at all?
Just a suggestion.......try using ElseIf ?
Quote from: DarkMinion on January 17, 2004, 03:50 PM
If you're going to let anybody use it why have an if at all?
Wow..... aight, its a vote command. Therefore, anyone in the channel must have access to Yes and No ( If username = username Then.... ). Voteoff command is only for the Master ( If username = LoadMaster Then... )
I will try elseif but i doubt it will solve my problem.
elseif wasnt suggested to solve ur problem it was suggested to clean up ur code :o
Quote from: LoRd]VeGiTo[ on January 19, 2004, 02:55 PM
elseif wasnt suggested to solve ur problem it was suggested to clean up ur code :o
If you are going suggest ways to clean up his code, my first suggestion would be to use a language that promotes it. My opinion is that VB6 and below doesn't. ;D Upgrade to VB.NET and then decouple the UI from the system. Keep in mind my suggestion is object oriented.
Quote from: UserLoser. on January 17, 2004, 02:59 PM
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
Reflexive property.
You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes).
Quote from: R.a.B.B.i.T on January 19, 2004, 06:18 PM
Quote from: UserLoser. on January 17, 2004, 02:59 PM
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
Reflexive property.
You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes).
That is basically what I was telling him to do... I think the benefits are that it would keep the system and UI separate, allowing for easier maintenance.
Quote from: OuTLawZGoSu on January 17, 2004, 12:20 PM
I got this:
I need to add theusername to the list when "Yes" or "No" is typed.
Exept, when the user types yes or no, nothing happens.
'Vote
'
If username = LoadMaster Then
If Left((LCase(message)), 5) = (LoadTrigger & "vote") Then
Form1.chkVote = vbChecked
AddQueue "Vote: " & (Mid(message, 6, Len(message) - 1))
End If
End If
If username = username And LCase(message) = "yes" Then
If username = Form1.voteuserchk.FindItem(x) Then
If Form1.chkVote = vbChecked Then Form1.LbYes.AddItem "Yes"
End If
Form1.voteuserchk.ListItems.add 1, , username
End If
If username = username And LCase(message) = "no" Then
If username = Form1.voteuserchk.FindItem(x) Then
If Form1.chkVote = vbChecked Then Form1.LbNo.AddItem "No"
End If
Form1.voteuserchk.ListItems.add 1, , username
End If
If username = LoadMaster And LCase(message) = "voff" Then
If Form1.chkVote = vbChecked Then
Form1.chkVote = vbUnchecked
Form1.txtYes = Form1.LbYes.ListCount
Form1.txtNo = Form1.LbNo.ListCount
AddQueue "Results: " & Form1.txtYes.text & " voted for Yes, " & Form1.txtNo.text & " voted for No."
Form1.LbYes.Clear
Form1.LbNo.Clear
Form1.txtYes.text = ""
Form1.txtNo.text = ""
Form1.voteuserchk.ListItems.Clear
End If
End If
Help?
I dunno if this would help but try
If username = username And LCase(message) = LCase("yes") Then
And
If username = username And LCase(message) = LCase("no") Then
Seems like a long shot, but I have had stranger things happen......
Also.....did that ElseIf help at all???
Quote from: ChR0NiC on January 19, 2004, 06:55 PM
I dunno if this would help but try
If username = username And LCase(message) = LCase("yes") Then
And
If username = username And LCase(message) = LCase("no") Then
That is quite pointless, seeing as how when you do LCase("yes") the result, is of course, "yes" (the same is true with "no"). As said previously, username = username is not needed. All you need is the following:
'// Sub Stuff..this is at the end..
If LCase(Message) = "yes" Then
If Not Voted(UserName) Then
Form1.lvVoted.ListItems.Add , , UserName
Form1.lvVotes.ListItems.Add , , "yes"
Else
'Send "/m " & UserName & " You have already voted."
' This is commented because if too many people vote _
and your queue sucks, it could flood the bot.
End If
ElseIf LCase(Message) = "no" Then
If Not Voted(UserName) Then
Form1.lvVoted.ListItems.Add , , UserName
Form1.lvVotes.ListItems.Add , , "no"
Else
'Send "/m " & UserName & " You have already voted."
' This is commented because if too many people vote _
and your queue sucks, it could flood the bot.
End If
End If
End Sub
Public Function Voted(CheckName As String) As Boolean
Voted = False
On Error Goto ErrorVote
Dim c As Integer
For c = 1 to Form1.lvVoted.ListItems.Count
If LCase(CheckName) = LCase(Form1.lvVoted.ListItems(c).Text) Then
Voted = True
Exit Function
End If
Next c
ErrorVote:
End Function
This works a lot better, and a lot quicker, albeit it requires 3 ListViews.
Then, once the vote is over, you can call this:
Public Function Results() As String
On Error GoTo ErrReport
Dim v As Integer, cYes As Integer, cNo As Integer
For v = 1 To Form1.lvVotes.ListItems.Count
If Form1.lvVotes.ListItems(v).Text = "yes" Then
cYes = cYes + 1
Else
cNo = cNo + 1
End If
Next v
Results = CStr(cYes) & "ß" & CStr(cNo)
Exit Function
ErrReport:
Results = "Error reporting results."
End Function.
I'm prettyr sure you can figure it out from there..
I agree, using this would be more efficient and I think he will discover it works.....
Quote from: R.a.B.B.i.T on January 19, 2004, 06:18 PM
Quote from: UserLoser. on January 17, 2004, 02:59 PM
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
Reflexive property.
You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes).
What would be so wrong with an integer?
Quote from: hismajesty on January 21, 2004, 02:24 PM
Quote from: R.a.B.B.i.T on January 19, 2004, 06:18 PM
Quote from: UserLoser. on January 17, 2004, 02:59 PM
I don't understand the purpose of "If username = username", it's the same as If 1 = 1
Reflexive property.
You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes).
What would be so wrong with an integer?
"If username = username" doesn't do anything, theres no way the username won't equal the username unless it's changed at the exact moment when the If is in the middle of checking. That part is 100% useless.
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)
Ah, I misunderstood the post. I was thinking he was using a listview/box for storing the votes.
I believe he was trying to say:
If username_you_got = username_you_want Then ...
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
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