Author | Message | Time |
---|---|---|
OuTLawZGoSu | 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. [code] '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 [/code] Help? | January 17, 2004, 6:20 PM |
UserLoser. | I don't understand the purpose of "If username = username", it's the same as If 1 = 1 | January 17, 2004, 8:59 PM |
OuTLawZGoSu | [quote author=UserLoser. link=board=17;threadid=4758;start=0#msg39958 date=1074373146] I don't understand the purpose of "If username = username", it's the same as If 1 = 1 [/quote] That just means If any user type in Yes or No then. | January 17, 2004, 9:48 PM |
DarkMinion | If you're going to let anybody use it why have an if at all? | January 17, 2004, 9:50 PM |
ChR0NiC | Just a suggestion.......try using ElseIf ? | January 18, 2004, 4:08 AM |
OuTLawZGoSu | [quote author=DarkMinion link=board=17;threadid=4758;start=0#msg39972 date=1074376246] If you're going to let anybody use it why have an if at all? [/quote] 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. | January 19, 2004, 8:22 PM |
Lord-Vegito | elseif wasnt suggested to solve ur problem it was suggested to clean up ur code :o | January 19, 2004, 8:55 PM |
Tuberload | [quote author=LoRd]VeGiTo[ link=board=17;threadid=4758;start=0#msg40193 date=1074545717] elseif wasnt suggested to solve ur problem it was suggested to clean up ur code :o [/quote] 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. | January 19, 2004, 9:37 PM |
R.a.B.B.i.T | [quote author=UserLoser. link=board=17;threadid=4758;start=0#msg39958 date=1074373146] I don't understand the purpose of "If username = username", it's the same as If 1 = 1 [/quote] Reflexive property. You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes). | January 20, 2004, 12:18 AM |
Tuberload | [quote author=R.a.B.B.i.T link=board=17;threadid=4758;start=0#msg40230 date=1074557892] [quote author=UserLoser. link=board=17;threadid=4758;start=0#msg39958 date=1074373146] I don't understand the purpose of "If username = username", it's the same as If 1 = 1 [/quote] Reflexive property. You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes). [/quote] 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. | January 20, 2004, 12:37 AM |
ChR0NiC | [quote author=OuTLawZGoSu link=board=17;threadid=4758;start=0#msg39919 date=1074363658] 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. [code] '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 [/code] Help? [/quote] I dunno if this would help but try [code] If username = username And LCase(message) = LCase("yes") Then [/code] And [code] If username = username And LCase(message) = LCase("no") Then [/code] Seems like a long shot, but I have had stranger things happen...... Also.....did that ElseIf help at all??? | January 20, 2004, 12:55 AM |
R.a.B.B.i.T | [quote author=ChR0NiC link=board=17;threadid=4758;start=0#msg40246 date=1074560149] I dunno if this would help but try [code] If username = username And LCase(message) = LCase("yes") Then [/code] And [code] If username = username And LCase(message) = LCase("no") Then [/code] [/quote] 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: [code] '// 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 [/code] This works a lot better, and a lot quicker, albeit it requires 3 ListViews. Then, once the vote is over, you can call this: [code] 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. [/code] I'm prettyr sure you can figure it out from there.. | January 20, 2004, 1:58 AM |
ChR0NiC | I agree, using this would be more efficient and I think he will discover it works..... | January 21, 2004, 4:03 PM |
hismajesty | [quote author=R.a.B.B.i.T link=board=17;threadid=4758;start=0#msg40230 date=1074557892] [quote author=UserLoser. link=board=17;threadid=4758;start=0#msg39958 date=1074373146] I don't understand the purpose of "If username = username", it's the same as If 1 = 1 [/quote] Reflexive property. You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes). [/quote] What would be so wrong with an integer? | January 21, 2004, 8:24 PM |
R.a.B.B.i.T | [quote author=hismajesty link=board=17;threadid=4758;start=0#msg40523 date=1074716690] [quote author=R.a.B.B.i.T link=board=17;threadid=4758;start=0#msg40230 date=1074557892] [quote author=UserLoser. link=board=17;threadid=4758;start=0#msg39958 date=1074373146] I don't understand the purpose of "If username = username", it's the same as If 1 = 1 [/quote] Reflexive property. You can make your voting at least 2ms faster by using arrays rather than listviews (or listboxes). [/quote] What would be so wrong with an integer? [/quote] "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. | January 21, 2004, 10:05 PM |
o.OV | I am not keen on using gui based items.. but I would like to help.. (*closes eyes*) Here is untested code: [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 [/code] 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) | January 22, 2004, 2:09 AM |
hismajesty | Ah, I misunderstood the post. I was thinking he was using a listview/box for storing the votes. | January 22, 2004, 2:43 AM |
Arta | I believe he was trying to say: [code] If username_you_got = username_you_want Then ... [/code] | January 22, 2004, 8:56 AM |
ChR0NiC | The [code]If Username = Username Then[/code] is basically saying........no matter what, the vote counts......but I just hope he knows he doesn't need to do that.....hehehehe | January 22, 2004, 1:26 PM |
ChR0NiC | [quote author=o.OV link=board=17;threadid=4758;start=15#msg40567 date=1074737381] In Outlaw's code.. What is FindItem(X) and what is X ? I have no clue how that works... [/quote] 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 | January 22, 2004, 1:30 PM |