Results 1 to 8 of 8

Thread: [RESOLVED] sending data instr?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Resolved [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!

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: sending data instr?

    You can send - separated with ;
    Code:
    part 3;then 1;then 2
    ... and split it with Split():
    VB Code:
    1. Dim arr() As String
    2.     arr() = Split(receivedString, ";");
    Now you have the array of "part 3", "then 1" and "then 2".

    Is this what you're after?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    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!

  4. #4
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: sending data instr?

    Sure, just make sure you use the same delimiter on each end.

    VB Code:
    1. sSendString = Data1 & "|" & Data2 & "|" & Data3

    then use Splt to make an array in the recieving program
    VB Code:
    1. Dim sRecievedData() as string
    2.     dim lX as long
    3.  
    4.     sRecievedData = split(sSendString, "|")
    5.     'Now use the data in any order you want
    6.     for lx = 0 to ubound(sRecievedData )
    7.         debug.print sRecievedData(lx)
    8.     next

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    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!

  6. #6
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    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:
    1. Dim sRecievedData() as string
    2.  
    3.     sRecievedData = Split ([B]theStringYouReceive[/B], "|")
    4.  
    5.         'when you split it with Split(), you have:
    6.  
    7.         'sReceivedData([B]0[/B]) = [B]Data1[/B]
    8.         'sReceivedData([B]1[/B]) = [B]Data2[/B]
    9.         'sReceivedData([B]2[/B]) = [B]Data3[/B]
    10.  
    11.         '... withouth those ("|") signs
    It seems to me that you don't undestand how Split() works. Check MSDN for more info on that

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Re: sending data instr?

    Thanks this works fine
    If a post has been usefull then Rate it!

  8. #8

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