This code was made to complete the NMEA code of a GPS.
This is the usual string. it is missing the $ at the begining and the *CC
where cc is the chechsum
GPGGA,204540.999,2041.1120,N,10326.9078,W,1,06,2.1,1501.0,M,,,,0000
This is the complete String.
$GPGGA,204540.999,2041.1120,N,10326.9078,W,1,06,2.1,1501.0,M,,,,0000*2 6
The uses of this code could be any you want, I am just saying what was the purpose of doing it. any questions about the code or the application contact me ok?
I am posting the complete Module. read the example code and you wil easily figure what does the Form1 includes, just two text and one button.
Public Sub CheckSum(ByVal InputString As String, ByRef sumcheck As Byte)
'PURPOSE: Calculate the Or-Exclusive checksum
' Designed for use in the NIME string of GPS
'PARAMETERS: InputString = The string to calculate checksum
' sumcheck = The Oe-Exclusive chexksum in a byte of the string
'
'Example
' Dim sumcheck As Byte
' Dim InputString As String
'
' InputString = Text1.Text
' CheckSum InputString, sumcheck
' Text2.Text = Hex(sumcheck)
'
'********************************************************************* ****
Dim I As Integer
Dim Tamaņo As Integer
Dim bytletters() As Byte
Tamaņo = Len(InputString)
bytletters = StrConv(InputString, vbFromUnicode)
sumcheck = 0
For I = 0 To Tamaņo - 1
sumcheck = sumcheck Xor bytletters(I)
Next I
End Sub