Results 1 to 30 of 30

Thread: Resolved : VB Winsock Help, IM Program Help Will Pay

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Resolved : VB Winsock Help, IM Program Help Will Pay

    Hello, I am looking for an experienced user in VB 6 that can help me fix some errors in my instant messenging program. I get it to connect, register whos online, etc. But when you send an im to a user over the internet, the receiver gets disconected. Please send me an email if you are willing to help, I can pay per job done. Please PM me if you are interested.
    Thanks,
    anony
    Last edited by anonyentry; May 27th, 2006 at 07:57 PM.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    Try: http://www.rentacoder.com

    also, don't post your email address on an open forum. bots will pick it up and you will get spammed. Edit your post and remove it.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    Thanks,
    Here is the exact error i get when a user IM's another:
    Run-Time Error 13
    Type mismatch
    Here is the code:
    VB Code:
    1. Private Sub cmdSend_Click()
    2. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    3. If typemsg.Text <> "" And Len(typemsg) > 0 Then
    4.     showmsg.SelStart = Len(showmsg.Text)
    5.     showmsg.SelBold = True
    6.     showmsg.SelColor = vbRed
    7.     showmsg.SelText = Client.Caption & ": "
    8.    
    9.    
    10.     showmsg.SelStart = Len(showmsg.Text)
    11.     showmsg.SelBold = False
    12.     showmsg.SelColor = vbBlack
    13.     showmsg.SelText = typemsg.Text & vbCrLf
    14.  
    15.     PlaySound ("sounds/imsend.wav")
    16.     Client.Winsock1.SendData ".msg " & Client.Caption & " " & Word(Me.Caption, 1) & " ..//.. " & typemsg.Text
    17.     Client.WaitFor (".msgOK")
    18.     typemsg.Text = ""
    19. End If
    20. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    21. typemsg.SetFocus
    22. End Sub

  4. #4
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    on what line do you get the error?

    also, both parts of this If construct do the same thing:
    VB Code:
    1. If typemsg.Text <> "" And Len(typemsg) > 0 Then
    2.  
    3. ' make it:
    4.  
    5. If Len(typemsg.Text) Then

  5. #5
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: VB Winsock Help, IM Program Help Will Pay

    Is any part of that hi-lighted when the error occurs?
    PHP in your FACE!

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    If LenLen doesnt work im trying If len now.

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    Quote Originally Posted by anonyentry
    If LenLen doesnt work im trying If len now.
    typo by me.

    should just be Len

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    it now is:
    VB Code:
    1. Private Sub cmdSend_Click()
    2. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    3. If Len(typemsg.Text) Then
    4.     showmsg.SelStart = Len(showmsg.Text)
    5.     showmsg.SelBold = True
    6.     showmsg.SelColor = vbRed
    7.     showmsg.SelText = Client.Caption & ": "
    8.    
    9.    
    10.     showmsg.SelStart = Len(showmsg.Text)
    11.     showmsg.SelBold = False
    12.     showmsg.SelColor = vbBlack
    13.     showmsg.SelText = typemsg.Text & vbCrLf
    14.  
    15.     PlaySound ("sounds/imsend.wav")
    16.     Client.Winsock1.SendData ".msg " & Client.Caption & " " & Word(Me.Caption, 1) & " ..//.. " & typemsg.Text
    17.     Client.WaitFor (".msgOK")
    18.     typemsg.Text = ""
    19. End If
    20. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    21. typemsg.SetFocus
    22. End Sub
    And i still get the same runtime error.

  9. #9
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    i wasn't suggesting a resolution of the error - i was just telling you you had some unneeded code.

    what line is the error occuring on? When the error happens click 'debug' and tell us which line is highlighted.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    In data arrival:
    VB Code:
    1. ElseIf Word(strIncoming, 1) = ".statusUpdate" And Word(strIncoming, 2) <> "0" Then
    2.         Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))

  11. #11
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    can you post the code for the Word function

  12. #12
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: VB Winsock Help, IM Program Help Will Pay

    I think were going to need more code...
    PHP in your FACE!

  13. #13

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    VB Code:
    1. Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    2.     Dim i As Long
    3.     Winsock1.GetData strIncoming
    4.    
    5.     If strIncoming = ".badlogin" Then
    6.         MsgBox "The screen name or password you entered is not valid. ", vbOKOnly + vbCritical
    7.         If Winsock1.State <> sckClosed Then
    8.             Winsock1.Close
    9.         End If
    10.     ElseIf strIncoming = ".goodlogin" Then
    11.         Call good_login
    12.        
    13.     ElseIf Word(strIncoming, 1) = ".showonline" And Word(strIncoming, 2) <> "0" Then
    14.         Call Show_Online_buddies(strIncoming)
    15.        
    16.     ElseIf Word(strIncoming, 1) = ".statusUpdate" And Word(strIncoming, 2) <> "0" Then
    17.         Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))
    18.        
    19.     ElseIf Word(strIncoming, 1) = ".msg" Then
    20.         Call get_message(Word(strIncoming, 2), strIncoming)
    21.        
    22.     ElseIf Word(strIncoming, 1) = ".define" Then
    23.         Call get_definition(Word(strIncoming, 2), Word(strIncoming, 3), strIncoming)
    24.        
    25.     ElseIf Word(strIncoming, 1) = ".spell" Then
    26.             Call get_spelling(Word(strIncoming, 2), strIncoming)
    27.  
    28.     End If
    29. End Sub

  14. #14
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    as I've already asked
    Quote Originally Posted by bushmobile
    can you post the code for the Word function
    and post the value of strIncoming

  15. #15

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    Owrd function:
    [Highlight=VB]Option Explicit

    Const SP As String = " "
    Dim pointer As Long 'start parameter of Instr()
    Dim pos As Long 'position of target in InStr()
    Dim x As Long 'word count
    Dim lEnd As Long 'position of trailing word delimiter

    sSource = CSpace(sSource)

    'find the nth word
    x = 1
    pointer = 1

    Do
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop
    If x = n Then 'the target word-number
    lEnd = InStr(pointer, sSource, SP) 'pos of space at end of word
    If lEnd = 0 Then lEnd = Len(sSource) + 1 ' or if its the last word
    Word = Mid$(sSource, pointer, lEnd - pointer)
    Exit Do 'word found, done
    End If

    pos = InStr(pointer, sSource, SP) 'find next space
    If pos = 0 Then Exit Do 'word not found
    x = x + 1 'increment word counter

    pointer = pos + 1 'start of next word
    Loop

    End Function

    Public Function Words(ByVal sSource As String) As Long
    '=================================================
    ' Words returns the number of words in a string
    ' Usage:
    ' Words("red blue green") 3
    '=================================================
    Const SP As String = " "
    Dim lSource As Long 'length of sSource
    Dim pointer As Long 'start parameter of Instr()
    Dim pos As Long 'position of target in InStr()
    Dim x As Long 'word count

    sSource = CSpace(sSource)
    lSource = Len(sSource)
    If lSource = 0 Then Exit Function

    'count words
    x = 1
    pointer = 1

    Do
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop
    pos = InStr(pointer, sSource, SP) 'find next space
    If pos = 0 Then Exit Do 'no more words
    x = x + 1 'increment word counter

    pointer = pos + 1 'start of next word
    Loop
    If Mid$(sSource, lSource, 1) = SP Then x = x - 1 'adjust if trailing space
    Words = x
    End Function

    Public Function WordCount(ByVal sSource As String, _
    sTarget As String) As Long
    '=====================================================
    ' WordCount returns the number of times that
    ' word, sTarget, is found in sSource.
    ' Usage:
    ' WordCount("a rose is a rose", "rose") 2
    '=================================================
    Const SP As String = " "
    Dim pointer As Long 'start parameter of Instr()
    Dim lSource As Long 'length of sSource
    Dim lTarget As Long 'length of sTarget
    Dim pos As Long 'position of target in InStr()
    Dim x As Long 'word count

    lTarget = Len(sTarget)
    lSource = Len(sSource)
    sSource = CSpace(sSource)


    'find target word
    pointer = 1
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop
    If pointer > lSource Then Exit Function 'sSource contains no words

    Do 'find position of sTarget
    pos = InStr(pointer, sSource, sTarget)
    If pos = 0 Then Exit Do 'string not found
    If Mid$(sSource, pos + lTarget, 1) = SP _
    Or pos + lTarget > lSource Then 'must be a word
    If pos = 1 Then
    x = x + 1 'word found
    ElseIf Mid$(sSource, pos - 1, 1) = SP Then
    x = x + 1 'word found
    End If
    End If
    pointer = pos + lTarget
    Loop
    WordCount = x

    End Function

    Public Function WordPos(ByVal sSource As String, _
    sTarget As String) As Long
    '=====================================================
    ' WordPos returns the word number of the
    ' word, sTarget, in sSource.
    ' Usage:
    ' WordPos("red blue green", "blue") 2
    '=================================================
    Const SP As String = " "
    Dim pointer As Long 'start parameter of Instr()
    Dim lSource As Long 'length of sSource
    Dim lTarget As Long 'length of sTarget
    Dim lPosTarget As Long 'position of target-word
    Dim pos As Long 'position of target in InStr()
    Dim x As Long 'word count

    lTarget = Len(sTarget)
    lSource = Len(sSource)
    sSource = CSpace(sSource)


    'find target word
    pointer = 1
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop
    If pointer > lSource Then Exit Function 'sSource contains no words

    Do 'find position of sTarget
    pos = InStr(pointer, sSource, sTarget)
    If pos = 0 Then Exit Function 'string not found
    If Mid$(sSource, pos + lTarget, 1) = SP _
    Or pos + lTarget > lSource Then 'must be a word
    If pos = 1 Then Exit Do 'word found
    If Mid$(sSource, pos - 1, 1) = SP Then Exit Do
    End If
    pointer = pos + lTarget
    Loop


    'count words until position of sTarget
    lPosTarget = pos 'save position of sTarget
    pointer = 1
    x = 1
    Do
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop
    If pointer >= lPosTarget Then Exit Do 'all words have been counted
    pos = InStr(pointer, sSource, SP) 'find next space
    If pos = 0 Then Exit Do 'no more words
    x = x + 1 'increment word count
    pointer = pos + 1 'start of next word
    Loop
    WordPos = x
    End Function

    Public Function WordIndex(ByVal sSource As String, _
    vTarget As Variant) As Long
    '===========================================================
    ' WordIndex returns the byte position of vTarget in sSource.
    ' vTarget can be a word-number or a string.
    ' Usage:
    ' WordIndex("two plus 2 is four", 2) 5
    ' WordIndex("two plus 2 is four", "2") 10
    ' WordIndex("two plus 2 is four", "two") 1
    '===========================================================
    Const SP As String = " "
    Dim sTarget As String 'vTarget converted to String
    Dim lTarget As Long 'vTarget converted to Long, or length of sTarget
    Dim lSource As Long 'length of sSource
    Dim pointer As Long 'start parameter of InStr()
    Dim pos As Long 'position of target in InStr()
    Dim x As Long 'word counter

    lSource = Len(sSource)
    sSource = CSpace(sSource)

    If VarType(vTarget) = vbString Then GoTo strIndex
    If Not IsNumeric(vTarget) Then Exit Function
    lTarget = CLng(vTarget) 'convert to Long

    'find byte position of lTarget (word number)
    x = 1
    pointer = 1


    Do
    Do While Mid$(sSource, pointer, 1) = SP 'skip consecutive spaces
    pointer = pointer + 1
    Loop

    If x = lTarget Then 'word-number of Target
    If pointer > lSource Then Exit Do 'beyond end of sSource
    WordIndex = pointer 'position of word
    Exit Do 'word found, done
    End If

    pos = InStr(pointer, sSource, SP) 'find next space
    If pos = 0 Then Exit Do 'word not found
    x = x + 1 'increment word counter
    pointer = pos + 1
    Loop

    Exit Function
    strIndex:
    sTarget = CStr(vTarget)
    lTarget = Len(sTarget)
    If lTarget = 0 Then Exit Function 'nothing to count

    'find byte position of sTarget (string)
    pointer = 1
    Do
    pos = InStr(pointer, sSource, sTarget)
    If pos = 0 Then Exit Do
    If Mid$(sSource, pos + lTarget, 1) = SP _
    Or pos + lTarget > lSource Then
    If pos = 1 Then Exit Do
    If Mid$(sSource, pos - 1, 1) = SP Then Exit Do
    End If
    pointer = pos + lTarget
    Loop

    WordIndex = pos

    End Function

    Public Function WordLength(ByVal sSource As String, _
    n As Long) As Long
    '=========================================================
    ' Wordlength returns the length of the nth word in sSource
    ' Usage:
    ' WordLength("red blue green", 2) 4
    '=========================================================

  16. #16

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    heres the rest:
    VB Code:
    1. Const SP    As String = " "
    2. Dim lSource As Long   'length of sSource
    3. Dim pointer As Long   'start parameter Instr()
    4. Dim pos     As Long   'position of target with InStr()
    5. Dim x       As Long   'word count
    6. Dim lEnd    As Long   'position of trailing word delimiter
    7.  
    8. sSource = CSpace(sSource)
    9. lSource = Len(sSource)
    10.  
    11. 'find the nth word
    12. x = 1
    13. pointer = 1
    14.  
    15. Do
    16.    Do While Mid$(sSource, pointer, 1) = SP     'skip consecutive spaces
    17.       pointer = pointer + 1
    18.    Loop
    19.    If x = n Then                               'the target word-number
    20.       lEnd = InStr(pointer, sSource, SP)       'pos of space at end of word
    21.       If lEnd = 0 Then lEnd = lSource + 1      '   or if its the last word
    22.       WordLength = lEnd - pointer
    23.       Exit Do                                  'word found, done
    24.    End If
    25.  
    26.    pos = InStr(pointer, sSource, SP)           'find next space
    27.    If pos = 0 Then Exit Do                     'word not found
    28.    x = x + 1                                   'increment word counter
    29.  
    30.    pointer = pos + 1                           'start of next word
    31. Loop
    32.  
    33. End Function
    34.  
    35. Public Function DelWord(ByVal sSource As String, _
    36.                                     n As Long, _
    37.                       Optional vWords As Variant) As String
    38. '===========================================================
    39. ' DelWord deletes from sSource, starting with the
    40. ' nth word for a length of vWords words.
    41. ' If vWords is omitted, all words from the nth word on are
    42. ' deleted.
    43. ' Usage:
    44. '   DelWord("now is not the time", 3)     "now is"
    45. '   DelWord("now is not the time", 3, 1)  "now is the time"
    46. '===========================================================
    47. Const SP    As String = " "
    48. Dim lWords  As Long    'length of sTarget
    49. Dim lSource As Long    'length of sSource
    50. Dim pointer As Long    'start parameter of InStr()
    51. Dim pos     As Long    'position of target in InStr()
    52. Dim x       As Long    'word counter
    53. Dim lStart  As Long    'position of word n
    54. Dim lEnd    As Long    'position of space after last word
    55.  
    56. lSource = Len(sSource)
    57. DelWord = sSource
    58. sSource = CSpace(sSource)
    59. If IsMissing(vWords) Then
    60.    lWords = -1
    61. ElseIf IsNumeric(vWords) Then
    62.    lWords = CLng(vWords)
    63. Else
    64.    Exit Function
    65. End If
    66.  
    67. If n = 0 Or lWords = 0 Then Exit Function      'nothing to delete
    68.  
    69. 'find position of n
    70. x = 1
    71. pointer = 1
    72.  
    73. Do
    74.    Do While Mid$(sSource, pointer, 1) = SP     'skip consecutive spaces
    75.       pointer = pointer + 1
    76.    Loop
    77.    If x = n Then                               'the target word-number
    78.       lStart = pointer
    79.       If lWords < 0 Then Exit Do
    80.    End If
    81.    
    82.    If lWords > 0 Then                          'lWords was provided
    83.       If x = n + lWords - 1 Then               'find pos of last word
    84.          lEnd = InStr(pointer, sSource, SP)    'pos of space at end of word
    85.          Exit Do                               'word found, done
    86.       End If
    87.    End If
    88.    
    89.    pos = InStr(pointer, sSource, SP)           'find next space
    90.    If pos = 0 Then Exit Do                     'word not found
    91.    x = x + 1                                   'increment word counter
    92.  
    93.    pointer = pos + 1                           'start of next word
    94. Loop
    95. If lStart = 0 Then Exit Function
    96. If lEnd = 0 Then
    97.    DelWord = Trim$(Left$(sSource, lStart - 1))
    98. Else
    99.    DelWord = Trim$(Left$(sSource, lStart - 1) & Mid$(sSource, lEnd + 1))
    100. End If
    101. End Function
    102.  
    103. Public Function MidWord(ByVal sSource As String, _
    104.                                     n As Long, _
    105.                       Optional vWords As Variant) As String
    106. '===========================================================
    107. ' MidWord returns a substring sSource, starting with the
    108. ' nth word for a length of vWords words.
    109. ' If vWords is omitted, all words from the nth word on are
    110. ' returned.
    111. ' Usage:
    112. '   MidWord("now is not the time", 3)     "not the time"
    113. '   MidWord("now is not the time", 3, 2)  "not the"
    114. '===========================================================
    115. Const SP    As String = " "
    116. Dim lWords  As Long    'vWords converted to long
    117. Dim lSource As Long    'length of sSource
    118. Dim pointer As Long    'start parameter of InStr()
    119. Dim pos     As Long    'position of target in InStr()
    120. Dim x       As Long    'word counter
    121. Dim lStart  As Long    'position of word n
    122. Dim lEnd    As Long    'position of space after last word
    123.  
    124. lSource = Len(sSource)
    125. sSource = CSpace(sSource)
    126. If IsMissing(vWords) Then
    127.    lWords = -1
    128. ElseIf IsNumeric(vWords) Then
    129.    lWords = CLng(vWords)
    130. Else
    131.    Exit Function
    132. End If
    133.  
    134. If n = 0 Or lWords = 0 Then Exit Function              'nothing to delete
    135.  
    136. 'find position of n
    137. x = 1
    138. pointer = 1
    139.  
    140. Do
    141.    Do While Mid$(sSource, pointer, 1) = SP     'skip consecutive spaces
    142.       pointer = pointer + 1
    143.    Loop
    144.    If x = n Then                               'the target word-number
    145.       lStart = pointer
    146.       If lWords < 0 Then Exit Do               'include rest of sSource
    147.    End If
    148.    
    149.    If lWords > 0 Then                          'lWords was provided
    150.       If x = n + lWords - 1 Then               'find pos of last word
    151.          lEnd = InStr(pointer, sSource, SP)    'pos of space at end of word
    152.          Exit Do                               'word found, done
    153.       End If
    154.    End If
    155.    
    156.    pos = InStr(pointer, sSource, SP)           'find next space
    157.    If pos = 0 Then Exit Do                     'word not found
    158.    x = x + 1                                   'increment word counter
    159.  
    160.    pointer = pos + 1                           'start of next word
    161. Loop
    162. If lStart = 0 Then Exit Function
    163. If lEnd = 0 Then
    164.    MidWord = Trim$(Mid$(sSource, lStart))
    165. Else
    166.    MidWord = Trim$(Mid$(sSource, lStart, lEnd - lStart))
    167. End If
    168. End Function
    169.  
    170. Public Function CSpace(sSource As String) As String
    171. '==================================================
    172. 'CSpace converts blank characters
    173. '(ascii: 9,10,13,160) to space (32)
    174. '
    175. '  cSpace("a" & vbTab   & "b")  "a b"
    176. '  cSpace("a" & vbCrlf  & "b")  "a  b"
    177. '==================================================
    178. Dim pointer   As Long
    179. Dim pos       As Long
    180. Dim x         As Long
    181. Dim iSpace(3) As Integer
    182.  
    183. ' define blank characters
    184. iSpace(0) = 9    'Horizontal Tab
    185. iSpace(1) = 10   'Line Feed
    186. iSpace(2) = 13   'Carriage Return
    187. iSpace(3) = 160  'Hard Space
    188.  
    189. CSpace = sSource
    190. For x = 0 To UBound(iSpace) ' replace all blank characters with space
    191.    pointer = 1
    192.    Do
    193.       pos = InStr(pointer, CSpace, Chr$(iSpace(x)))
    194.       If pos = 0 Then Exit Do
    195.       Mid$(CSpace, pos, 1) = " "
    196.       pointer = pos + 1
    197.    Loop
    198. Next x
    199.  
    200. End Function
    201.  
    202. Public Function SplitString(iSource As String, iTarget As String, Optional BeforeTarget As Boolean = False) As String
    203. '==================================================
    204. 'Returns the characters before or after the split
    205. 'identifier. By default will return text after id,
    206. 'set BeforeTarget as true to return the text before
    207. 'it.
    208. '==================================================
    209. If BeforeTarget = True Then
    210.    SplitString = DelWord(iSource, WordPos(iSource, iTarget))
    211. Else
    212.    SplitString = DelWord(iSource, 1, WordPos(iSource, iTarget))
    213. End If
    214.  
    215. End Function
    [/Highlight]

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    What's the declaration for the Word function, you've missed it off.

    on the error, does it highlight
    VB Code:
    1. ElseIf Word(strIncoming, 1) = ".statusUpdate" And Word(strIncoming, 2) <> "0" Then
    or
    VB Code:
    1. Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))

  18. #18

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))

  19. #19
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: VB Winsock Help, IM Program Help Will Pay

    Whats the code and declaration of that function? And what's the value of strIncoming? Also, just in case... what's the declaration of strIncoming?

    Best to use a procedure level variable to hold the stream returned by GetData. strIncoming can be overwriiten by other data arrivals while midway through a data arrival.

  20. #20

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    The declaration is above in the large code post.
    VB Code:
    1. Dim dWord As String
    2.  
    3. Private Sub cmbFonts_Click()
    4.     typemsg.SelFontName = cmbFonts.Text
    5.     typemsg.SetFocus
    6. End Sub
    7.  
    8. Private Sub cmdSend_Click()
    9. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    10. If Len(typemsg.Text) Then
    11.     showmsg.SelStart = Len(showmsg.Text)
    12.     showmsg.SelBold = True
    13.     showmsg.SelColor = vbRed
    14.     showmsg.SelText = Client.Caption & ": "
    15.    
    16.    
    17.     showmsg.SelStart = Len(showmsg.Text)
    18.     showmsg.SelBold = False
    19.     showmsg.SelColor = vbBlack
    20.     showmsg.SelText = typemsg.Text & vbCrLf
    21.  
    22.     PlaySound ("sounds/imsend.wav")
    23.     Client.Winsock1.SendData ".msg " & Client.Caption & " " & Word(Me.Caption, 1) & " ..//.. " & typemsg.Text
    24.     Client.WaitFor (".msgOK")
    25.     typemsg.Text = ""
    26. End If
    27. typemsg.Text = Replace(typemsg.Text, vbCrLf, "")
    28. typemsg.SetFocus
    29. End Sub
    30.  
    31. Private Sub Form_Load()
    32. Dim i As Integer
    33.     mnuFont.Visible = False
    34.     mnuSpellDefine2.Visible = False
    35.     'bAllowScroll = True
    36.     'Call SetHook(showmsg.hwnd, True)
    37.     For i = 1 To Screen.FontCount
    38.         cmbFonts.AddItem Screen.Fonts(i)
    39.     Next i
    40.     cmbFonts.RemoveItem (0)
    41.     cmbFonts.SelText = "Verdana"
    42. End Sub
    43.  
    44. 'Private Sub Form_Unload(Cancel As Integer)
    45.     'Call SetHook(showmsg.hwnd, False)
    46. 'End Sub
    47.  
    48. Private Sub mnuFontBold_Click()
    49.  
    50. If typemsg.SelBold = True Then
    51.    typemsg.SelBold = False
    52.    tbFonts.Buttons(1).Value = tbrUnpressed
    53. Else
    54.    typemsg.SelBold = True
    55.    tbFonts.Buttons(1).Value = tbrPressed
    56. End If
    57.  
    58. End Sub
    59.  
    60. Private Sub mnuFontItalic_Click()
    61.  
    62. If typemsg.SelItalic = True Then
    63.    typemsg.SelItalic = False
    64.    tbFonts.Buttons(2).Value = tbrUnpressed
    65. Else
    66.    typemsg.SelItalic = True
    67.    tbFonts.Buttons(2).Value = tbrPressed
    68. End If
    69.  
    70. End Sub
    71.  
    72. Private Sub mnuFontUnderline_Click()
    73.  
    74. If typemsg.SelUnderline = True Then
    75.    typemsg.SelUnderline = False
    76.    tbFonts.Buttons(3).Value = tbrUnpressed
    77. Else
    78.    typemsg.SelUnderline = True
    79.    tbFonts.Buttons(3).Value = tbrPressed
    80. End If
    81.  
    82. End Sub
    83.  
    84. Private Sub mnuFontPT_Click(Index As Integer)
    85.    typemsg.SelFontSize = Word(mnuFontPT(Index).Caption, 1)
    86. End Sub
    87.  
    88. Private Sub showmsg_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    89. If Button = vbRightButton Then
    90.        If showmsg.SelText <> "" And is_chars(Replace(Trim(showmsg.SelText), vbCrLf, "")) = True Then
    91.             dWord = Replace(Trim(showmsg.SelText), vbCrLf, "")
    92.         Else
    93.             dWord = "- Please highlight a word."
    94.         End If
    95.         mnuSpell2.Caption = "Spellcheck " & dWord
    96.         mnuDefine2.Caption = "Define " & dWord
    97.         PopupMenu mnuSpellDefine2
    98. End If
    99. End Sub
    100.  
    101. Private Function is_chars(x As String) As Boolean
    102. Dim i As Integer
    103. Dim flag As Integer
    104. For i = 1 To Len(x)
    105.     If (Asc(UCase(Mid(x, i, 1))) >= vbKeyA And Asc(UCase(Mid(x, i, 1))) <= vbKeyZ) Or Mid(x, i, 1) = " " Then
    106.         flag = 0
    107.     Else
    108.         flag = 1
    109.         Exit For
    110.         is_chars = False
    111.     End If
    112. Next i
    113.  
    114. If flag = 0 Then
    115.     is_chars = True
    116. End If
    117.    
    118. End Function
    119.  
    120. Private Sub tbFonts_ButtonClick(ByVal Button As MSComctlLib.Button)
    121.  
    122. Select Case Button.Index
    123.     Case 1
    124.         mnuFontBold_Click
    125.     Case 2
    126.         mnuFontItalic_Click
    127.     Case 3
    128.         mnuFontUnderline_Click
    129.     Case 5
    130.         If typemsg.SelFontSize > 8 Then
    131.             typemsg.SelFontSize = typemsg.SelFontSize - 2
    132.         End If
    133.     Case 6
    134.         If typemsg.SelFontSize < 14 Then
    135.             typemsg.SelFontSize = typemsg.SelFontSize + 2
    136.         End If
    137. End Select
    138.  
    139. End Sub
    140.  
    141. Private Sub typemsg_KeyDown(KeyCode As Integer, Shift As Integer)
    142. If KeyCode = vbKeyRight Or KeyCode = vbKeyLeft Or KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then
    143.     typemsg_Click
    144. End If
    145. End Sub
    146.  
    147. Private Sub typemsg_KeyPress(KeyAscii As Integer)
    148. If KeyAscii = vbKeyReturn Then
    149.     Call cmdSend_Click
    150. End If
    151. End Sub
    152.  
    153. Private Sub typemsg_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    154. On Error GoTo HandleError
    155. If Button = vbRightButton Then
    156.         If typemsg.SelText <> "" And is_chars(Replace(Trim(typemsg.SelText), vbCrLf, "")) = True Then
    157.             dWord = Replace(Trim(typemsg.SelText), vbCrLf, "")
    158.         Else
    159.             dWord = "- Please highlight a word."
    160.         End If
    161.         mnuSpell.Caption = "Spellcheck " & dWord
    162.         mnuDefine.Caption = "Define " & dWord
    163.    
    164.     If typemsg.SelBold = True Then
    165.        mnuFontBold.Checked = True
    166.     Else
    167.        mnuFontBold.Checked = False
    168.     End If
    169.    
    170.     If typemsg.SelItalic = True Then
    171.        mnuFontItalic.Checked = True
    172.     Else
    173.        mnuFontItalic.Checked = False
    174.     End If
    175.    
    176.     If typemsg.SelUnderline = True Then
    177.        mnuFontUnderline.Checked = True
    178.     Else
    179.        mnuFontUnderline.Checked = False
    180.     End If
    181.     PopupMenu mnuFont
    182. End If
    183.  
    184. HandleError:
    185.     'MsgBox Err.Number & " - " & Err.Description, vbOKOnly
    186. End Sub
    187.  
    188. Private Sub typemsg_Click()
    189. If cmbFonts.Text <> typemsg.SelFontName Then
    190.     cmbFonts.Text = ""
    191.     cmbFonts.SelText = typemsg.SelFontName
    192. End If
    193.  
    194.     If typemsg.SelBold = True Then
    195.        tbFonts.Buttons(1).Value = tbrPressed
    196.     Else
    197.        tbFonts.Buttons(1).Value = tbrUnpressed
    198.        
    199.     End If
    200.    
    201.     If typemsg.SelItalic = True Then
    202.        tbFonts.Buttons(2).Value = tbrPressed
    203.     Else
    204.        tbFonts.Buttons(2).Value = tbrUnpressed
    205.     End If
    206.    
    207.     If typemsg.SelUnderline = True Then
    208.        tbFonts.Buttons(3).Value = tbrPressed
    209.     Else
    210.        tbFonts.Buttons(3).Value = tbrUnpressed
    211.     End If
    212. End Sub
    213.  
    214. Private Sub mnuSpell_Click()
    215.     Call DefineSpell(".spell")
    216. End Sub
    217.  
    218. Private Sub mnuDefine_Click()
    219.     Call DefineSpell(".define")
    220. End Sub
    221.  
    222. Private Sub mnuSpell2_Click()
    223.     Call DefineSpell(".spell")
    224. End Sub
    225.  
    226. Private Sub mnuDefine2_Click()
    227.     Call DefineSpell(".define")
    228. End Sub
    229.  
    230. Private Function DefineSpell(wtd As String)
    231. If Word(dWord, 1) <> "-" Then
    232.     'MsgBox "Gonna DO IT", vbOKOnly
    233.     Client.Winsock1.SendData wtd & " " & Word(Me.Caption, 1) & " " & dWord
    234.     Client.WaitFor (wtd)
    235. End If
    236. End Function

  21. #21
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    All the code you just posted is irrelevant. what's the function / sub declaration of status_update, i.e. where it goes:

    Private Function status_update(..................

  22. #22
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: VB Winsock Help, IM Program Help Will Pay

    In addition to the pending requests... I would like to see the code of WaitFor

  23. #23

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    May be irrelevant but for sign on/off:
    VB Code:
    1. Private Function status_update(buddy As String, status As Integer)
    2.     Dim tn As Node
    3.     Dim n As String
    4.     Dim frmNum As Integer
    5.  
    6.         If status = 2 Then
    7.             n = "Offline"
    8.         Else
    9.             n = "Online"
    10.         End If
    11.     For Each tn In TreeView1.Nodes
    12.         If LCase(tn.Key) = LCase(buddy) Then
    13.             'TreeView1.Nodes.Remove tn.Key
    14.             'TreeView1.Nodes.Add n, tvwChild, buddy, buddy, status, status
    15.             If Word(TreeView1.Nodes(tn.Key).Parent, 1) <> "Buddies" Then
    16.                 If status = 1 Then
    17.                     Call PlaySound("sounds\dooropen.wav")
    18.                     runlog.SelStart = Len(runlog.Text)
    19.                     runlog.SelColor = vbBlue
    20.                     runlog.SelText = buddy & " has signed on (" & Time & ")" & vbCrLf
    21.                 End If
    22.                 If status <> 2 Then
    23.                     frmNum = GetFormNumber(LCase(buddy))
    24.                     If frmNum <> 0 Then
    25.                         Forms(frmNum).cmdSend.Enabled = True
    26.                         Forms(frmNum).typemsg.Enabled = True
    27.                         Forms(frmNum).tbFonts.Enabled = True
    28.                         Forms(frmNum).showmsg.SelStart = Len(Forms(frmNum).showmsg.Text)
    29.                         Forms(frmNum).showmsg.SelColor = vbBlue
    30.                         Forms(frmNum).showmsg.SelText = buddy & " has signed on (" & Time & ")." & vbCrLf
    31.                     End If
    32.                 End If
    33.             End If
    34.             If Word(TreeView1.Nodes(tn.Key).Parent, 1) <> "Offline" Then
    35.                 If status = 2 Then
    36.                     Call PlaySound("sounds\doorslam.wav")
    37.                     runlog.SelStart = Len(runlog.Text)
    38.                     runlog.SelColor = vbRed
    39.                     runlog.SelText = buddy & " has signed off (" & Time & ")" & vbCrLf
    40.                     frmNum = GetFormNumber(LCase(buddy))
    41.                     If frmNum <> 0 Then
    42.                         Forms(frmNum).cmdSend.Enabled = False
    43.                         Forms(frmNum).typemsg.Enabled = False
    44.                         Forms(frmNum).tbFonts.Enabled = False
    45.                         Forms(frmNum).showmsg.SelStart = Len(Forms(frmNum).showmsg.Text)
    46.                         Forms(frmNum).showmsg.SelColor = vbRed
    47.                         Forms(frmNum).showmsg.SelText = buddy & " has signed off (" & Time & ")." & vbCrLf
    48.                     End If
    49.                 End If
    50.             End If
    51.             TreeView1.Nodes.Remove tn.Key
    52.             TreeView1.Nodes.Add n, tvwChild, buddy, buddy, status, status
    53.             Call Online_Offline_Text
    54.             Exit For
    55.         End If
    56.     Next
    57. End Function

  24. #24

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    WaitFor:
    VB Code:
    1. Private Sub TreeView2_AfterLabelEdit(Cancel As Integer, NewString As String)
    2. Dim tn As Node
    3. If oldLabel <> "Buddies" Then
    4.     If UCase(NewString) <> UCase(oldLabel) Then
    5.         If Correct_Screenname(NewString) = True Then
    6.             If check_for_duplicate(NewString) = True Then
    7.                 TreeView2.SelectedItem.Key = NewString
    8.                 For Each tn In TreeView1.Nodes
    9.                     If UCase(tn.Key) = UCase(oldLabel) Then
    10.                         tn.Key = NewString
    11.                         tn.Text = NewString
    12.                         Winsock1.SendData ".updateBuddy " & LCase(Me.Caption) & " " & oldLabel & " " & NewString
    13.                         WaitFor (".statusUpdate")
    14.                         Exit For
    15.                     End If
    16.                 Next
    17.             Else
    18.                 MsgBox "A buddy with the user name " & UCase(NewString) & " already exists.", vbOKOnly + vbCritical
    19.                 Cancel = 1
    20.             End If
    21.             Else
    22.                 Cancel = 1
    23.             End If
    24.         Else
    25.             Cancel = 1
    26.         End If
    27.     Else
    28.         Cancel = 1
    29. End If
    30. End Sub

  25. #25
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    here's your error:
    VB Code:
    1. Private Function status_update(buddy As String, status As Integer)
    you are passing two strings to this function here:
    VB Code:
    1. Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))
    If Word(strIncoming, 4) is definitely a number try:
    VB Code:
    1. Call status_update(Word(strIncoming, 3), Val(Word(strIncoming, 4)))

  26. #26

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    So, I should delete Call status_update(Word(strIncoming, 3), Word(strIncoming, 4))
    ?

  27. #27
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    have you tried doing:
    VB Code:
    1. Call status_update(Word(strIncoming, 3), Val(Word(strIncoming, 4)))

  28. #28

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    Ok, when i replaced Call status_update(Word(strIncoming, 3), Word(strIncoming, 4)) with
    Call status_update(Word(strIncoming, 3), Val(Word(strIncoming, 4)))
    The runtime error stopped so I then compiled. Here is what happens now.*edit
    When a user sends someone an IM, the first one is not seen by the receiever, the second time they send one a box pops up for the receiver. I think I know why, the first time someone sends an IM to someone on their buddy list, instead of the im popping up for the receiver, the sender then appears online. After the receiver appears online for both buddies, they can talk freely. Although, they both must appear online for each buddy, and this is only done so by sending 1 im, or by having 1 buddy sign in when the other is allready signed in.
    Last edited by anonyentry; May 27th, 2006 at 03:41 PM.

  29. #29

    Thread Starter
    Junior Member
    Join Date
    May 2006
    Posts
    21

    Re: VB Winsock Help, IM Program Help Will Pay

    Mabey, is there a way to program it so when the first message sent to start a concersation includes2, one blank one wich signs the sender on in the receiver's list and then the message the sender types?

  30. #30
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: VB Winsock Help, IM Program Help Will Pay

    I'm afraid I don't know anything about WinSock.

    Perhaps work out what your question is, and then post a new thread. That way you've got more chance of people looking (as very few are likely to wade through all these posts).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width