CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2014

    GSM data shifting continuously

    I have written a code to get the GSM data on serial port. So when GSM module get's a call it sends the data

    RING+CLIP: "+919823596784",145,"",,"",0".

    However this data keeps on shifting towards right or left. I want to extract the phone number from this data. I thought of detecting first two word i.e RING+CLIP, using Instr function. However even it is present in incoming string, it's giving value 0' it means string is not present in given string. So i can not extract phone number. Moreover data keeps on shifting, so position of those two words is also not fix. Here is the code,

    Dim str As String
    Dim val As Integer
    Dim str_1 As String
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Form_Load()
       On Error GoTo errx:
       Dim strValue As String ' define Buffer value from Modem
       MSComm1.CommPort = 6   'comm port no.
       MSComm1.Settings = "9600,n,8,1"
       MSComm1.RThreshold = 47    'no. of chr to receive
       MSComm1.InputLen = 0  '  no. of chr on which oncomm  event fires
       MSComm1.PortOpen = True  'open comm port
       MSComm1.Output = "AT + CLIP = 1" + Chr(13)
       Sleep 500
       Exit Sub
     MsgBox "error"
    End Sub
    Private Sub MSComm1_OnComm()
    'str = " RING+CLIP"
    Select Case MSComm1.CommEvent
    Case comEvReceive
    ''Case comEvRing
    str_1 = Text1.Text
    Text2.Text = InStr(str_1, "RING+CLIP")
    ''Text3.Text = Mid(str, 22, 10)
    Case Else
    End Select
    End Sub
    How to stop shifting of data, and extract desired number from this.

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: GSM data shifting continuously

    I'd let in 2 Rings, and then parse. Caller ID comes in after the first ring.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Hanover Germany

    Re: GSM data shifting continuously

    Quote Originally Posted by djc_247 View Post
    I have written a code to get the GSM data on serial port. So when GSM module get's a call it sends the data

    RING+CLIP: "+919823596784",145,"",,"",0".
    I guess it should be something like
    +CLIP: "+919823596784",145,"",,"",0"
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.