Click here to Skip to main content
15,302,655 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
    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
Posted
Updated 4-Oct-13 5:13am
v2
Comments
TrushnaK 4-Oct-13 8:08am
   
what is your question?
abbaskhanx 4-Oct-13 8:13am
   
i want to know here is my mistake in codes
abbaskhanx 4-Oct-13 8:14am
   
For x As Integer = 0 To xxx.Items.Count - 1
'error is here but i can not understand it
addx = LCase(Microsoft.VisualBasic.Left(add, InStr(add, "/") - 1))
emox = LCase(Microsoft.VisualBasic.Left(listbox1.Items(x), InStr(listbox1.Items(x), "/") - 1))
If addx.ToUpper <> emox.ToUpper Then
xxx.Items.Add(add)


Else
in this part there is some error
Thomas ktg 4-Oct-13 8:16am
   
Post the error you are getting.
abbaskhanx 4-Oct-13 9:56am
   
:D there is no error i get
addx and emox funtion that is added its not working sir

1 solution

Um.
Look above that:
VB
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 If
Shouldn't that last one be "End Sub"? :laugh:
   
Comments
abbaskhanx 4-Oct-13 8:27am
   
bro i know that and i write half of these code but error is not in this part see in comments
For x As Integer = 0 To xxx.Items.Count - 1
'error is here but i can not understand it
addx = LCase(Microsoft.VisualBasic.Left(add, InStr(add, "/") - 1))
emox = LCase(Microsoft.VisualBasic.Left(listbox1.Items(x), InStr(listbox1.Items(x), "/") - 1))
If addx.ToUpper <> emox.ToUpper Then
xxx.Items.Add(add)


Else
'do nothing
Exit For
OriginalGriff 4-Oct-13 8:43am
   
Yes - but if you fix that, the later "errors" may well disappear...
abbaskhanx 4-Oct-13 9:04am
   
if addx and emox is same then ADD should not be added in xxx.items list
OriginalGriff 4-Oct-13 9:28am
   
So: what is in the two variables?
Have you used the debugger to look at them?
abbaskhanx 4-Oct-13 9:34am
   
addx is like "hi/hello"
and emox should match left side of "/" in listbox
if "hi" is already in listbox items then "add" should not added
OriginalGriff 4-Oct-13 9:41am
   
So what exactly values do you see in the debugger?
Not "should match" and "should not": we (and you) need to know exactly what values you do get...
Kschuler 4-Oct-13 9:44am
   
You keep saying "should"...what we need want to know is did you debug it and see that this is actually happening by QuickWatching the variables? Also, what is the exact error message that you are getting?
abbaskhanx 4-Oct-13 11:14am
   
I update full code and comments that i found error please check and give me solution
abbaskhanx 4-Oct-13 11:16am
   
please take a look VB.NET master :)
OriginalGriff 4-Oct-13 11:26am
   
Code doesn't help without the data.
So look at it in the debugger! You do know how to use the debugger, don't you?
abbaskhanx 4-Oct-13 11:31am
   
Yes i debug it there is no error i got on debug but when i run this application and i add new item with like add#hi/hello it is added more then 3 times in xxx.list
OriginalGriff 4-Oct-13 11:38am
   
Good! So when you put a breakpoint on the line:
If addx.ToUpper <> emox.ToUpper Then
What values does the debugger show in addx and emox?
Not what should it show, what does it show? And remember, this is in a loop, so you will need to look several times and write them down (or better, copy and paste)
abbaskhanx 4-Oct-13 11:59am
   
addx value is like "hello/here any word"
emox walue is also like "hello/here any word" "hi/any word" "hey/any word" in listbox

if emox found "hello" is already in list box then it shows message "this is already exist"
abbaskhanx 4-Oct-13 12:00pm
   
i want to match LCase of "/" of list items
OriginalGriff 4-Oct-13 12:14pm
   
No, "like" is not what we need. We need exactly.

Your code compares the two strings exactly. It doesn't say "is this similar to that?" it says "is this exactly the same as that?" and it behaves differently depending on the result. So you need to know exactly what you are comparing, so you can work backwards through the code to find out why it isn't what you think it is.
abbaskhanx 4-Oct-13 12:25pm
   
ok Thanks For your Time
Can you give me your yahoo or gmail user name ?
OriginalGriff 4-Oct-13 12:44pm
   
No! :laugh:

Do you have any idea how many emails I get a day as it is? :OMG:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900