Results 1 to 9 of 9

Thread: Winsock And Split Function(RESOLVED)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Winsock And Split Function(RESOLVED)

    I need to know how to use the split function. I have a program I wrote using the split function and it works but the one I am writing doesnt seem to want to work

    for instance I have a client when the use clicks send it does this

    sckSend.SendData strName & strMsg

    I need the host to take it and split it to two variables like this

    Private Sub sckAccept_DataArrival(ByVal bytesTotal As Long)
    sckAccept.GetData Data, vbString, bytesTotal

    I need it to get the data and then split it to its necessary variables likes this on the data accept do this

    MsgBox " strName & strMsg "

    I am basically asking how to assign the data received to variables for use in the server
    Last edited by baked_noodle; Mar 2nd, 2005 at 12:25 AM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock And Split Function

    You have to send it with a character that you use to split the data. If you use the space character, then it would split on first name and last name in addition to the message. Perhaps you could use the ~ character. This would be easy to split.

    VB Code:
    1. dim arr() as string
    2. arr = Split(mystring,"~")

    then arr(0) is the name and arr(1) is the message

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Winsock And Split Function

    Use a delimiter before sending the data
    sckSend.SendData strName & "|" & strMsg
    Then split it this way
    MyData = Split(Data, "|", 2)
    MsgBox MyData(0) & " " & MyData(1)

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: Winsock And Split Function

    How can I tell what is assigned to Data(0) and Data(1) my program doesnt seem to use the values of these variables

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock And Split Function

    How did you split Data?

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: Winsock And Split Function

    VB Code:
    1. Private Sub sckAccept_DataArrival(ByVal bytesTotal As Long)
    2. sckAccept.GetData Data, vbString, bytesTotal
    3. Data2() = Split(Data, "|", 2)
    4. Shell "C:\Windows\system32\cmd.exe /C net send" & Data2(0) & " " & Data2(1)
    5. End Sub
    Last edited by baked_noodle; Mar 1st, 2005 at 11:01 PM.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock And Split Function

    Quote Originally Posted by baked_noodle
    VB Code:
    1. Private Sub sckAccept_DataArrival(ByVal bytesTotal As Long)
    2. sckAccept.GetData Data, vbString, bytesTotal
    3. Data2() = Split(Data, "|", 2)
    4. Shell "C:\Windows\system32\cmd.exe /C net send" & Data2(0) & " " & Data2(1)
    5. End Sub
    You forgot the space after Net Send, try it like this:

    VB Code:
    1. Shell ("C:\Windows\system32\cmd.exe /C net send " & Data2(0) & " " & Data2(1)), vbNormalFocus

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2005
    Posts
    21

    Re: Winsock And Split Function

    its always something dumb like that thanks

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Winsock And Split Function(RESOLVED)

    A second pair of eyes find more errors than eight hours staring at a screen.

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