本文介绍了用于列表框的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 私有 Sub f_OnRoomMessage( ByVal MyFrbSocket 作为 frbclient, ByVal RoomName 作为 字符串, ByVal Id As 字符串, ByVal 消息 As 字符串)句柄 f.OnRoomMessage 开 错误 恢复 下一步 如果 Id = msterid.Text 或 Id = m ind,hunter 或 Id = master2.Text 或 Id = master3.Text 然后 如果消息= bot / on 或消息= Bot / on 然后 f.WriteRoomMessage(room.Text, 我准备好了;)) CheckBox1.Checked = True 结束 如果 如果消息= Bot / off 或消息= bot / off 然后 f.WriteRoomMessage(room.Text, 睡眠时间(a)) CheckBox1.Checked = False 结束 如果 如果 Message.ToUpper = SHOW / MSG 然后 对于 x 作为 整数 = 0 xxx.Items.Count - 1 f.WriteRoomMessage(room.Text,xxx.Items(x)& vbCrLf) 下一步 结束 如果 If InStr( 1 ,Message, DEL#,vbTextCompare)<> 0 然后 Dim addd 作为 字符串 如果 InStr ( 1 ,消息, # ,vbTextCompare)<> 0 然后 addd = Mid(消息,InStr(消息, #)+ 1 ) 对于 x 作为 整数 = 0 xxx.Items.Count - 1 如果 addd = xxx.Items(x)那么 xxx.Items.RemoveAt(x) f.WriteRoomMessage(room.Text, 已移除:D) 退出 对于 E nd 如果 下一步 结束 如果 结束 如果 如果 InStr( 1 ,消息, ADD#,vbTextCompare)<> 0 然后 Dim add 作为 字符串 如果 InStr ( 1 ,消息, # ,vbTextCompare)<> 0 然后 add = Mid(消息,InStr(消息, #)+ 1 ) check(add ) 结束 如果 结束 如果 结束 如果 如果 CheckBox1.Checked = True 然后 对于 i 作为 整数 = 0 xxx.Items.Count - 1 Dim 回复作为 字符串 Dim emo As String 如果 InStr( 1 ,xxx.Items.Item(i), /,vbTextCompare)<> 0 然后 reply = Mid(xxx.Items.Item(i),InStr(xxx) .Items.Item(i), /)+ 1 ) emo = LCase(Microsoft.VisualBasic.Left(xxx.Items.Item(i),InStr(xxx.Items.Item(i), /) - 1 )) 如果 emo.ToUpper = Message.ToUpper 那么 f.WriteRoomMessage(room.Text,reply) 结束 如果 结束 如果 下一步 结束 如果 结束 Sub 私有 Sub 检查(添加) Dim emox 作为 字符串 Dim addx 作为 字符串 对于 x 作为 整数 = 0 xxx.Items.Count - 1 ' 这里我想匹配如果addx是和emox相同那么ADD不应该添加到listbox xxx ' 错误在这里使用此ADD会在xxx.items(x)中添加很多时间,并且addx和emox不匹配 addx = LCase(Microsoft.VisualBasic.Left(add,InStr(add, /) - 1 )) emox = LCase(Microsoft.VisualBasic.Left(xxx.Items(x).ToString,InStr(xxx.Items(x).ToString, /) - 1 )) ' 此功能不起作用 如果 emox.ToString.ToUpper = addx.ToUpper 然后 f.WriteRoomMessage(room.Text, Paa Ji This + addx + 已经存在:D ) 退出 对于 否则 xxx.Items.Add(add) f.WriteRoomMessage(room.Text, 已添加;)) 结束 如果 下一步 ' 这种方式只读取和匹配最后添加的项目 ' Dim emox As String ' Dim addx As String ' 对于i = 0到xxx.Items.Count - 1 ' Dim i如Integer =(xxx.Items.C ount - 1) ' addx = LCase(Microsoft.VisualBasic.Left(add,InStr) (添加,/) - 1)) ' emox = LCase(Microsoft。 VisualBasic.Left(xxx.Items(i),InStr(xxx.Items(i),/) - 1)) ' ' 如果addx.ToUpper = emox .ToUpper然后 ' f.WritePrivateMessage(Id& @ nimbuzz.com,Paa Ji This+ addx +已经存在:D) ' Else ' xxx.Items.Add(add) ' 结束如果 结束 Sub 解决方案 嗯。 上面看: 私人 Sub f_OnRoomMessage(消息) ' 消息就像添加#hiii / helo 如果 InStr( 1 ,消息, ADD#,vbTextCompare)<> 0 然后 Dim add 作为 字符串 如果 InStr ( 1 ,消息, # ,vbTextCompare)<> 0 然后 add = Mid(消息,InStr(消息, #)+ 1 ) check(add ) 结束 如果 结束 如果 结束 如果 最后一个不应该是End Sub吗? :笑: Private Sub f_OnRoomMessage(ByVal MyFrbSocket As frbclient, ByVal RoomName As String, ByVal Id As String, ByVal Message As String) Handles f.OnRoomMessage On Error Resume Next If Id = msterid.Text Or Id = "mind,hunter" Or Id = master2.Text Or Id = master3.Text Then If Message = "bot/on" Or Message = "Bot/on" Then f.WriteRoomMessage(room.Text, "I'm Ready ;)") CheckBox1.Checked = True End If If Message = "Bot/off" Or Message = "bot/off" Then f.WriteRoomMessage(room.Text, "Time To Sleep (a)") CheckBox1.Checked = False End If If Message.ToUpper = "SHOW/MSG" Then For x As Integer = 0 To xxx.Items.Count - 1 f.WriteRoomMessage(room.Text, xxx.Items(x) & vbCrLf) Next End If If InStr(1, Message, "DEL#", vbTextCompare) <> 0 Then Dim addd As String If InStr(1, Message, "#", vbTextCompare) <> 0 Then addd = Mid(Message, InStr(Message, "#") + 1) For x As Integer = 0 To xxx.Items.Count - 1 If addd = xxx.Items(x) Then xxx.Items.RemoveAt(x) f.WriteRoomMessage(room.Text, "Removed :D") Exit For End If Next End If End If If InStr(1, Message, "ADD#", vbTextCompare) <> 0 Then Dim add As String If InStr(1, Message, "#", vbTextCompare) <> 0 Then add = Mid(Message, InStr(Message, "#") + 1) checking(add) End If End If End If If CheckBox1.Checked = True Then For i As Integer = 0 To xxx.Items.Count - 1 Dim reply As String Dim emo As String If InStr(1, xxx.Items.Item(i), "/", vbTextCompare) <> 0 Then reply = Mid(xxx.Items.Item(i), InStr(xxx.Items.Item(i), "/") + 1) emo = LCase(Microsoft.VisualBasic.Left(xxx.Items.Item(i), InStr(xxx.Items.Item(i), "/") - 1)) If emo.ToUpper = Message.ToUpper Then f.WriteRoomMessage(room.Text, reply) End If End If Next End If End Sub Private Sub checking(add) Dim emox As String Dim addx As String For x As Integer = 0 To xxx.Items.Count - 1 'here i want to match if addx is and emox is same then "ADD" should not added to listbox xxx 'error is here with this "ADD" is add many time in xxx.items(x) and addx and emox did not match addx = LCase(Microsoft.VisualBasic.Left(add, InStr(add, "/") - 1)) emox = LCase(Microsoft.VisualBasic.Left(xxx.Items(x).ToString, InStr(xxx.Items(x).ToString, "/") - 1))'this function is not working w If emox.ToString.ToUpper = addx.ToUpper Then f.WriteRoomMessage(room.Text, "Paa Ji This " + addx + " Is Already Exist :D ") Exit For Else xxx.Items.Add(add) f.WriteRoomMessage(room.Text, "Added ;)") End If Next 'This Way It Read and match only last added item ' Dim emox As String ' Dim addx As String ' For i = 0 To xxx.Items.Count - 1 ' Dim i As Integer = (xxx.Items.Count - 1) ' addx = LCase(Microsoft.VisualBasic.Left(add, InStr(add, "/") - 1)) ' emox = LCase(Microsoft.VisualBasic.Left(xxx.Items(i), InStr(xxx.Items(i), "/") - 1)) ' ' If addx.ToUpper = emox.ToUpper Then 'f.WritePrivateMessage(Id & "@nimbuzz.com", "Paa Ji This " + addx + " Is Already Exist :D ") ' Else ' xxx.Items.Add(add) ' End If End Sub 解决方案 Um.Look above that:Private Sub f_OnRoomMessage(Message) 'Message is like add#hiii/helo If InStr(1, Message, "ADD#", vbTextCompare) <> 0 Then Dim add As String If InStr(1, Message, "#", vbTextCompare) <> 0 Then add = Mid(Message, InStr(Message, "#") + 1) checking(add) End If End If End IfShouldn't that last one be "End Sub"? :laugh: 这篇关于用于列表框的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 17:18