Results 1 to 4 of 4

Thread: Parse serial data

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Noblesville, IN.USA
    Posts
    2

    Post

    I have the following data streaming in from a serial device:

    "Wxxx Fxxxxxxxx|ID S xxxxxx|ID E xxxxxx|Wxxx Fxxxxxxxx"

    I need to parse it so that when the code see's the "|", it will do a carriage return and the data streaming in from the serial device will look like this:

    Wxxx Fxxxxxxxx
    ID S xxxxxx
    ID E xxxxxx
    Wxxx Fxxxxxxxx

    I appreciate any help or code snippets you can offer. this is my first attempt at programming!

    Regards,

    Michael


  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Assuming you are using VB6:
    Code:
        Dim str As String
        Dim newstr As String
        
        
        str = "Wxxx Fxxxxxxxx|ID S xxxxxx|ID E xxxxxx|Wxxx Fxxxxxxxx"
        
        newstr = Replace(str, "|", vbCrLf)
        
        MsgBox newstr
    Tom

  3. #3
    Guest

    Post

    or you could do this if you need to edit the data rapidly

    dim Mystring$ 'contains serial data
    dim MyArray() 'variant array
    dim i% 'for...next counter

    myarray = split(mystring, "|") 'cuts up the 'data into segments between the pipe 'characters "|".

    for i = 0 to ubound(myarray)
    me.print myarray(i)
    next i

    [email protected]

    [This message has been edited by wossname (edited 01-09-2000).]

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Noblesville, IN.USA
    Posts
    2

    Post

    I need to add that the data stream coming in from the serial port will be in random order, and will always be broken up by "|".
    I also want to display this data in a text box....


    thank you for your help!

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