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.
Re: Winsock recieve data help
This will split the words. What you do with firstTwo and lastFew is up to you :wave:
VB Code:
Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
Dim arr() as String
Dim firstTwo$, lastFew$, x%
' get the data and display it in the textbox
Winsock.GetData strData
' ---------------------------------------------------
arr() = Split(strData, " ") ' Split into words
firstTwo = arr(0) & " " & arr(1) ' First two words
for x=2 to Ubound(arr)
lastFew = lastFew & arr(x) & " " ' Rest of the words
next x
' ---------------------------------------------------
txtMain.Text = txtMain.Text & vbCrLf & "Client: " & strData
txtMain.SelStart = Len(txtMain.Text)
End Sub
Re: Winsock recieve data help [Resolved]