How to extract only message from sms in VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arunbojan
    New Member
    • Jul 2008
    • 30

    How to extract only message from sms in VB.NET

    Hi,

    Im working in mobile application using vb.net.... I read the stored sms from my simcard using GSM modem connected to my system. The sms i retrived from sim contains all details like (date, time, phone number) etc..... My question is, how to retrive only message.

    I have stored the complete sms in a variable..... i tried using split and substring functions..... I didnt get the solution ......


    Thanks in advance :)
    Last edited by arunbojan; Sep 6 '08, 05:49 AM. Reason: title changed
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Well, post the format that you receive an sms in. Is it one long string? Is in an object?

    Post it.

    Comment

    • arunbojan
      New Member
      • Jul 2008
      • 30

      #3
      Originally posted by insertAlias
      Well, post the format that you receive an sms in. Is it one long string? Is in an object?

      Post it.

      Thanks for your response......

      following is the format of sms....

      Code:
      AT+CMGR=2
      
      +CMGR: "REC READ","121",,"07/04/18,15:26:01+00"
      (1/2)Roam with Airtel at 56% reduced National roaming rates and no monthly rental. All local calls-Rs1.40/min, incoming calls-Rs1.75/min, STD calls-Rs2.40/mi
      
      OK
      my requirement is, I need to extract only 4th line....

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        Originally posted by arunbojan
        Thanks for your response......

        following is the format of sms....

        Code:
        AT+CMGR=2
        
        +CMGR: "REC READ","121",,"07/04/18,15:26:01+00"
        (1/2)Roam with Airtel at 56% reduced National roaming rates and no monthly rental. All local calls-Rs1.40/min, incoming calls-Rs1.75/min, STD calls-Rs2.40/mi
        
        OK
        my requirement is, I need to extract only 4th line....
        When you say "the 4th line" is all that a single string, with a line feed at the end of each line? I'd say, figure out whether the end of line is a carriage return, a line feed or a combination of both and do a split. For example - if it's a carriage return and line feed: Let's say your data is held in the string variable Data

        Dim UsefulData As String = Data.Split(vbCr Lf)(3)

        If it's just a line feed:

        Dim UsefulData As String = Data.Split(vbLf )(3)

        Have you tried those?...

        Comment

        • arunbojan
          New Member
          • Jul 2008
          • 30

          #5
          Originally posted by balabaster
          When you say "the 4th line" is all that a single string, with a line feed at the end of each line? I'd say, figure out whether the end of line is a carriage return, a line feed or a combination of both and do a split. For example - if it's a carriage return and line feed: Let's say your data is held in the string variable Data

          Dim UsefulData As String = Data.Split(vbCr Lf)(3)

          If it's just a line feed:

          Dim UsefulData As String = Data.Split(vbLf )(3)

          Have you tried those?...

          Hi Bala,

          Thanks a lot, your post gave me the solution.....

          Arun :)

          Comment

          • balabaster
            Recognized Expert Contributor
            • Mar 2007
            • 798

            #6
            Originally posted by arunbojan
            Hi Bala,

            Thanks a lot, your post gave me the solution.....

            Arun :)
            No problem, which worked? It's useful for other people to know should someone else search for a solution. I note that in many systems (UNIX for instance) that there is only a line feed (which I think is Chr(10) - or vbLF), but in Windows systems provide a carriage return and a line feed (as per the old typewriter) which is Chr(10) & Chr(13) ... or vbCrLf. Often when you're parsing text files, it's useful to remember that the text file may not have originally come from a Windows system, and as such, if your structure relies on an end of line, then you need to be aware of the differences.

            Comment

            Working...