Results 1 to 9 of 9

Thread: Parsing Data

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2003
    Posts
    419

    Parsing Data

    Hi, I have a string that my program is receiving that is in the following format:

    xxxxx;xxxxx;xxx;xxx;xxx;xxxx;0

    There is 6 series of numbers (of varying lengths)...divided by a semicolon...and then ending with a ;0.

    How can I parse out the last set of x's before the ;0?
    Code:
    If LostAngel.Tag = "Programming" then
       LostAngel.Caption = "Awake"
    Else
       LostAngel.Caption = "Dreaming of Code"
    End If

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Parsing Data

    Code:
    Dim arrSeries() As String
    Dim strSeries As String
    strSeries = "xxxxx;xxxxx;xxx;xxx;xxx;xxxx;0"
    arrSeries = Split(strSeries,";")
    The last series of x's will be arrSeries(5)

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Parsing Data

    Splitting on ";" will give you an array as posted by Hack. arSeries at Ubound(arrSeries) would be zero so your last batch of xxxx's would be at arrSeries(Ubound(arrSeries)-1)

  4. #4
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Re: Parsing Data

    Isn't that the same thing as arrSeries(5)?
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  5. #5
    Addicted Member
    Join Date
    Jun 2006
    Posts
    172

    Re: Parsing Data

    Since you don't seem to be using the 0.. you can drop it off before the Split() function.

    vb Code:
    1. strSeries = Mid(strSeries, 1, Len(strSeries) - 2)

    Works either way though.
    • If you found my post to be helpful, please rate me.

  6. #6
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Parsing Data

    Quote Originally Posted by SeanK
    Isn't that the same thing as arrSeries(5)?
    Didn't bother to count, my point of reference was the delimiter and zero, not the first character to the left. Parsing is mostly about repetitive patterns and selecting point of reference ...not just counting characters. what if there were hundreds of characters on either side?

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Parsing Data

    As long as the delimiter is a semi-colon, it really wouldn't matter how many characters there were on either side.

  8. #8
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Parsing Data

    But then he'd be counting semicolons to hardcode the index.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Parsing Data

    Valid point.

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