|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Filter / Parse String.
I have been working on returning the NMEA String from a Trimble UNit. With help from many of you (especially NoFriends) I have reached a point where I can read the NMEA string, Bring it into Access, and display it in a text box or MsgBox. My next two steps and the last two are to filter this NMEA Message down to the String I am looking for. I am attempting to do this below and have been unsuccessful to date. I am trying to grab the $GPGGA string but am still returning all strings with different begining codes such as $GPGLL etc.....Second I then need to parse this string. I dont see this as being much of an issue. If I can get the return NMEA message broken down to one sprcific string and written to a variable I can handle parcing it out. Any help would be apprecaited.
Anyone have ideas how I can modify the below code to filter out all the other strings...and just grab the string starting with $GPGGA? For some reason it does NOT go into the first "Case $GPGGA" Statement looking for the $GPGGA string. Obviosly because it does not recognize the $GPGGA string.....But I know its in the NMEA Message because I can see it in the TextBox. Although there are many strings...I think I need to filter it upon reading the CommPort. Does that make sense? It the goes into the "Case Else" statements and it is here that I can push it to a text box or the MsbBox..... Code: Option Compare Database Private Sub Form_Load() If (Not MSComm6.PortOpen) Then ' Buffer to hold input string Dim Instring As String ' Use COM1. MSComm6.CommPort = 1 ' 9600 baud, no parity, 8 data, and 1 stop bit. MSComm6.Settings = "9600,N,8,1" ' Tell the control to read entire buffer when Input is used. MSComm6.InputLen = 0 ' Open the port. MSComm6.PortOpen = True ' Send the attention command to the modem. MSComm6.Output = "AT" & vbCr ' Ensure that the modem responds with "OK". ' Wait for data to come back to the serial port. Buffer$ = Buffer$ & MSComm6.Input MsgBox "SMS Port Open", vbOKOnly, "Port State" Else MsgBox "SMS Port Already Open", vbOKOnly, "Port State" End If Call MSComm6_OnComm End Sub '_______________________________________________ Public Sub MSComm6_OnComm() 'Attempting to Return a value from the port Select Case MSComm6.CommEvent Case "$GPGGA" MsgBox "ENTERING CASE STATEMENT" Dim NMEAString As String NMEAString = MSComm6.Input If InStr(NMEAString, "$GPGGA") > 0 Then MsgBox NMEAString End If Case Else Dim NMEAString1 As String Forms!GPS_RETRIEVE!TEXTBOX.SetFocus 'MSComm6.InBufferCount = 0 NMEAString1 = MSComm6.Input If InStr(NMEAString1, "$GPGGA") > 0 Then ' Converting the return so I can read it TEXTBOX.Text = NMEAString1 Else MsgBox "NO DEAL" End If End Select End Sub |
|
#2
|
|||
|
|||
|
Can't you step through your code with the VB Debugger and determine what's wrong?
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
The code below or above is working.....it goes into the second case statement and returns all the NMEA strings. I am unsure how the string actually comes in and how to grab just a portion of it. I push the output from the GPS Unit, which is sitting at the Comm Port into a text box. THere are a bunch of Strings sitting there. Thats why I have the first Case statement set up to look for strings $GPGGA. For some reason that is not working, and as such it goes into the second case stamtment and returns all of them.
I am using Access and the debugger within....I dont know how the debugger will help me filter the string. I am asking for a little help how to start to filter the string. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Filter / Parse String. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|