老师 下面代码,校验通过时,出错提示啊,快帮看看问题在哪里啊,谢谢,谢谢
内部函数:GPS校验
Dim GPSstr As String = args(0)
Dim result As Boolean
Dim S As String = GPSstr.trim()
Dim n1 As Integer = S.IndexOf("$")+1
Dim n2 As Integer = S.LastIndexOf("*")-1
Dim SR As String = S.SubString(S.LastIndexOf("*")+1)
S = S.SubString(n1,n2-n1+1)
Dim cs(s.length-1) As String
For i As Integer = 0 To s.length-1
cs(i) = S.SubString(i,1)
Next
Dim RR As Integer = ASC(cs(0))
For i As Integer = 1 To s.length-1
RR=RR xor ASC(cs(i))
Next
If RR = HexToDec(SR) Then
result =True
Else
result =False
End If
Return result
全局代码:
Public datetime_GPRMC As Date
Public jd_GPRMC As Double
Public jb_GPRMC As String
Public wd_GPRMC As Double
Public wb_GPRMC As String
Public Function Make_我要的GPS数据(GPSstr As String) As Boolean
Dim result As Boolean= Functions.Execute("GPS校验",GPSstr)
If result Then
Dim cs() As String = GPSstr.Trim().Split(",") ''每列 *** rs(i).Trim().
'' ------------------ Longdatetimestr 2020-03-13 09:54:46
Dim yyyy As String ="20" & cs(9).SubString(4,2)
Dim yy As String =cs(9).SubString(2,2)
Dim dd As String =cs(9).SubString(0,2)
Dim hh As String =cs(1).SubString(0,2)
Dim mm As String =cs(1).SubString(2,2)
Dim ss As String =cs(1).SubString(4)
datetime_GPRMC = Cdate(yyyy & "-" & yy & "-" & dd & " " & hh & ":" & mm & ":" & ss)
'' ------------------ jd 118.1085966666 24.4887866666
jd_GPRMC = GPSStrToVal(cs(5).trim())
jb_GPRMC = cs(6).trim()
wd_GPRMC = GPSStrToVal(cs(3).trim())
wb_GPRMC = cs(4).trim()
End If
Return result
End Function
命令窗口:
Dim GPSstr As String ="$GPVTG,89.68,T,,M,0.00,N,0.0,K*5F"
Dim b As Boolean =Make_我要的GPS数据(GPSstr)
msgbox(b)
不好意思 找到问题了 我的错误,打搅了!!
[此贴子已经被作者于2020/3/18 17:51:38编辑过]