Results 1 to 3 of 3

Thread: Winsock recieve data help [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    4

    Winsock recieve data help [Resolved]

    my code works, but i want to add something to it

    Code:
    Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    
    Dim strData As String
    
        ' get the data and display it in the textbox
    
        Winsock.GetData strData
    
        txtMain.Text = txtMain.Text & vbCrLf & "Client: " & strData
    
        txtMain.SelStart = Len(txtMain.Text)
    
    End Sub
    i want to make it take the first two words of the string, and have the first go into one variable and the second go into another, then all words after the first two get put in yet another variable. how would i go about doing this?

    edit: i also want it to still put all of the string into the text box.
    Last edited by camman977; Apr 28th, 2005 at 03:32 PM.

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

    Re: Winsock recieve data help

    This will split the words. What you do with firstTwo and lastFew is up to you

    VB Code:
    1. Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    2.  
    3. Dim strData As String
    4. Dim arr() as String
    5. Dim firstTwo$, lastFew$, x%
    6.  
    7.     ' get the data and display it in the textbox
    8.  
    9.     Winsock.GetData strData
    10.  
    11.     ' ---------------------------------------------------
    12.     arr() = Split(strData, " ")  ' Split into words
    13.     firstTwo = arr(0) & " " & arr(1)  ' First two words
    14.     for x=2 to Ubound(arr)
    15.       lastFew = lastFew & arr(x) & " " ' Rest of the words
    16.     next x
    17.     ' ---------------------------------------------------
    18.  
    19.     txtMain.Text = txtMain.Text & vbCrLf & "Client: " & strData
    20.  
    21.     txtMain.SelStart = Len(txtMain.Text)
    22.  
    23. End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    4

    Re: Winsock recieve data help [Resolved]

    thanks

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