Results 1 to 2 of 2

Thread: Multiple strings via winsock

  1. #1
    Guest

    Question

    How can I send multiple strings with winsock was the question. It might not be very hard to type 'Winsock1.SenData' multiple times, but getting the strings to end up in different places isn't quite as easy (according to me). So what I want to know is: How can I make different strings which were sent through winsock, to go to different textboxes. I've seen a method using different functions such as 'InStr', 'Left$' and 'Mid' (or something like that), but I have no idea how to use these functions. Anybody wanna help me? Please?

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    On the sender's side :

    Code:
    Dim i As Long
    Dim var_temp As String
    For i = 0 to UBound(Textbox)
         var_temp = var_temp & "_!_" & Textbox(i).Text
    Next i
    Winsock1.SendData var_temp
    Then, on the receiver's side :

    Code:
    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
         Dim var_sockdata As String
         Dim var_temp() As String
         Dim i as long
         
         Winsock1.GetData var_sockdata, vbString
         var_temp = Split(var_sockdata, "_!_", -1,vbTextCompare)
         For i = 0 To UBound(Textbox)
              Textbox(i).Text = var_temp(i)
         Next i
    End Sub

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