|
-
Dec 22nd, 2006, 12:34 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] sending data instr?
hey
i currently have a small program that uses 4 winsocks, and i obviously want it to be less than that, i was hoping someone could help me, i have seen instr() seems like a good thing to do but i am not sure how to do this and i have not found very useful posts or tutorial's on how to do this.
is it possible to send data in a string seperated by a chr or 2 and then the next bit of data etc and with that at the other end can it read a particular part of the string? say you have 3 parts seperated can it read (this is random order):
part 3 then 1 then 2?
if you know of a good tutorial or can help me out with this that would be great thanks!
lee
If a post has been usefull then Rate it! 
-
Dec 22nd, 2006, 01:56 PM
#2
Re: sending data instr?
You can send - separated with ;
Code:
part 3;then 1;then 2
... and split it with Split():
VB Code:
Dim arr() As String
arr() = Split(receivedString, ";");
Now you have the array of "part 3", "then 1" and "then 2".
Is this what you're after?
-
Dec 22nd, 2006, 01:59 PM
#3
Thread Starter
Hyperactive Member
Re: sending data instr?
yes kind of but is there any way to identify the parts as the parts may change?
If a post has been usefull then Rate it! 
-
Dec 22nd, 2006, 02:02 PM
#4
Re: sending data instr?
Sure, just make sure you use the same delimiter on each end.
VB Code:
sSendString = Data1 & "|" & Data2 & "|" & Data3
then use Splt to make an array in the recieving program
VB Code:
Dim sRecievedData() as string
dim lX as long
sRecievedData = split(sSendString, "|")
'Now use the data in any order you want
for lx = 0 to ubound(sRecievedData )
debug.print sRecievedData(lx)
next
-
Dec 22nd, 2006, 02:31 PM
#5
Thread Starter
Hyperactive Member
Re: sending data instr?
ok, i dont get how i can tell the difference between each of peices of data.
say i wanted data1 to be the caption of my form and data 2/3 to appear in a label how would that be done?
If a post has been usefull then Rate it! 
-
Dec 22nd, 2006, 03:24 PM
#6
Re: sending data instr?
This is what you send (for example):
Code:
sSendString = Data1 & "|" & Data2 & "|" & Data3
... and this is what you do with it when you receive it:
VB Code:
Dim sRecievedData() as string
sRecievedData = Split ([B]theStringYouReceive[/B], "|")
'when you split it with Split(), you have:
'sReceivedData([B]0[/B]) = [B]Data1[/B]
'sReceivedData([B]1[/B]) = [B]Data2[/B]
'sReceivedData([B]2[/B]) = [B]Data3[/B]
'... withouth those ("|") signs
It seems to me that you don't undestand how Split() works. Check MSDN for more info on that
-
Dec 22nd, 2006, 03:40 PM
#7
Thread Starter
Hyperactive Member
Re: sending data instr?
Thanks this works fine
If a post has been usefull then Rate it! 
-
Dec 22nd, 2006, 04:00 PM
#8
Re: [RESOLVED] sending data instr?
You're welcome
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
|