Bread a Long string in sub string that have known starting and ending strings.

I am reading  text data from a serial port.  The long text has several sub data strings.  At time the first few characters are not apart  of the sub data string.  The first part of each sub data string starts with a $ and ends with sum check or *66.  I need to remove each of the sub strings and read them into an array.  

First problem is that trash data must be removed from the start of the long string and from the end.  I do not find a funtion that will remove these trash or remove those characters.

Second I do not know how to remove the four or five sub string that are in the long serial port string.  The long string may look like this "12345$WIWMM,5.5,23,A,B,C*$GPRMC,111111.27,A,00000.10878,N,00000.10878,W,5.0,315,0,1*57236789"
 
Once the Sub string are read I can read the data on the sub string, but I con not know how to remove and read each sub string.

Visual Basic .Net is being used and it does not allow sum VB6  function.


Thomas
ThomasBurginAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
so is this the ORIGINAL string:

"12345$WIWMM,5.5,23,A,B,C*$GPRMC,111111.27,A,00000.10878,N,00000.10878,W,5.0,315,0,1*57236789"

and would the first suub-string then be

WIWMM,5.5,23,A,B,C

and the next substring would be:

GPRMC,111111.27,A,00000.10878,N,00000.10878,W,5.0,315,0,1

Is that correct so far.

Or could you give examples of what you mean by 'garbage' string, and the substrings that you expect from this original string

AW
0
ThomasBurginAuthor Commented:
The garbage would be 12345 of the long string and the garbage would be 236789 on the end.  The *57 is the check sum.  A check sum should be before the $GPRMC of the second sub string.  I forgot to put in in  The check sum would be *?? at the end of each sum string

Thomas
0
Shiju SasidharanAssoc Project ManagerCommented:
hi ThomasBurgin
 that means in a given string ur meaning ful data starts with

  $ symbol and ends with *??
   where ? is any digit
and u need a function to extract this ?
  is this right ?

;-)
Shiju
0
JigglyDCommented:
Okay, let's see if I have this straight...

The "potential input stream" could be:
     12345$WIWMM,5.5,23,A,B,C*??$GPRMC,111111.27,A,00000.10878,N,00000.10878,W,5.0,315,0,1*57236789
...and you are positive that each sub-string will be prefixed with $, and suffixed with *??

Well, to abate your initial concerns, the .NET platform will support many of the VB6 functions you have come to know and love.  For example, Microsoft.VisualBasic.Right(SourceString, 5) will return the five rightmost characters... just like in VB6.  Many others exist... just type in Microsoft.VisualBasic.   and watch the context sensitive menu spring to life.

Now, regarding your parsing problem, try this...
     Dim ResultArray() As String
     Dim Bucket As String

     Bucket = "12345$WIWMM,5.5,23,A,B,C*??$GPRMC,111111.27,A,00000.10878,N,00000.10878,W,5.0,315,0,1*57236789"

     If InStr(Bucket, "$") Then
          Bucket = Mid(Bucket, InStr(Bucket, "$") + 1)  '*** Remove prefixed garbage, and the leading $
         '*** Remove the suffixed garbage
          If Len(Bucket) >= 4 Then
               Do While Mid(Bucket, Len(Bucket) - 3) <> "*"
                    Bucket = Mid(Bucket, 1, Len(Bucket) - 1)
               Loop
          End If
         '*** Establish you result array
          ResultArray = Split(Bucket, "$")
     End If


Now you will be left with a string array of each of your sub-string (without the leading dollar signs)... and each array value will still contain your checksum value.

Jiggle On ! ! !
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.