|
-
Mar 1st, 2005, 02:08 AM
#1
Thread Starter
Junior Member
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.
-
Mar 1st, 2005, 02:16 AM
#2
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:
dim arr() as string
arr = Split(mystring,"~")
then arr(0) is the name and arr(1) is the message
-
Mar 1st, 2005, 02:24 AM
#3
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)
-
Mar 1st, 2005, 10:05 PM
#4
Thread Starter
Junior Member
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
-
Mar 1st, 2005, 10:12 PM
#5
Re: Winsock And Split Function
-
Mar 1st, 2005, 10:27 PM
#6
Thread Starter
Junior Member
Re: Winsock And Split Function
VB Code:
Private Sub sckAccept_DataArrival(ByVal bytesTotal As Long)
sckAccept.GetData Data, vbString, bytesTotal
Data2() = Split(Data, "|", 2)
Shell "C:\Windows\system32\cmd.exe /C net send" & Data2(0) & " " & Data2(1)
End Sub
Last edited by baked_noodle; Mar 1st, 2005 at 11:01 PM.
-
Mar 2nd, 2005, 12:15 AM
#7
Re: Winsock And Split Function
 Originally Posted by baked_noodle
VB Code:
Private Sub sckAccept_DataArrival(ByVal bytesTotal As Long)
sckAccept.GetData Data, vbString, bytesTotal
Data2() = Split(Data, "|", 2)
Shell "C:\Windows\system32\cmd.exe /C net send" & Data2(0) & " " & Data2(1)
End Sub
You forgot the space after Net Send, try it like this:
VB Code:
Shell ("C:\Windows\system32\cmd.exe /C net send " & Data2(0) & " " & Data2(1)), vbNormalFocus
-
Mar 2nd, 2005, 12:24 AM
#8
Thread Starter
Junior Member
Re: Winsock And Split Function
its always something dumb like that thanks
-
Mar 2nd, 2005, 12:35 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|