vb读取几种导航仪表的方法集合

前端之家收集整理的这篇文章主要介绍了vb读取几种导航仪表的方法集合前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
仪表主要有日本GP30,GP31,GP91,SAMYANG,另外还有国产的仪表,以供大家参考,这是本人为航务公司开发读取导航仪表的数据,数据主要有航速、经度、纬度和其它数据,但是其公司使用的导航仪有4种,每一种都写一个读数方法,所以是很郁闷的,好在最后都写出来了。
Dim tmpStr As String
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim l As Integer
    Dim RetValue
    
    On Error Resume Next
    
    Dim TmpA As String
    Dim TmpB As String
    Dim TmpC As String
    Dim TmpD As String
    Dim TmpE As String
    
    RetValue = MSCGps.Input
    j = LenB(RetValue)
    
    For i = 0 To j - 1
        If RetValue(i) = &H24 And RetValue(i + 1) = &HA0 And j > 31 Then
           For k = 0 To 3
              TmpA = TmpA & Replace(Format(Hex(RetValue(i + 6 + k)),"@@")," ","0")
           Next
           LblInfo(0).Caption = Val(TmpA) / 1000 '经度
         
           For k = 0 To 3
              TmpB = TmpB & Replace(Format(Hex(RetValue(i + 10 + k)),"0")
           Next
           LblInfo(1).Caption = Val(TmpB) / 1000 '纬度
          
           For k = 0 To 1
              TmpC = TmpC & Replace(Format(Hex(RetValue(i + 14 + k)),"0")
           Next
           LblInfo(2).Caption = Val(TmpC)        '速度
          
           For k = 0 To 1
              TmpD = TmpD & Replace(Format(Hex(RetValue(i + 16 + k)),"0")
           Next
           Label2(7).Caption = TmpD              '方位
    
          TmpE = TmpE & Replace(Format(Hex(RetValue(i + 18)),"0")
       
          Label2(6).Caption = TmpE               '状态
          
        End If
    
    Next
    
    
'    tmpStr = MSCGps.Input
'    StrBuf = tmpStr
    
    '$GPRMC,055214,A,3158.0956,N,12024.4596,E,0.0,326,200511,5,W*68\CR\LF

'    If UCase(Mode) = "GP31" Then
'        i = InStr(1,tmpStr,"$GPRMC",vbTextCompare)
'        If i Then
'             LblInfo(0).Caption = Val(Mid(tmpStr,i + 16,2)) & " " & Val(Mid(tmpStr,i + 18,7))                      '经度
'             LblInfo(1).Caption = Mid(tmpStr,i + 28,3) & " " & Mid(tmpStr,i + 31,7)                                '纬度
'             LblInfo(2).Caption = Val(Mid(tmpStr,i + 41,4))                                                          '速度
'             LblInfo(3).Caption = Mid(tmpStr,i + 7,2) & ":" & Mid(tmpStr,i + 9,i + 11,2)   '时间
'        End If
'
'        '$GPVTG,T,302,M,K\CR\LF
'        j = InStr(1,"$GPVTG",vbTextCompare)
'        If j Then
'             Label2(7).Caption = Val(Mid(tmpStr,j + 10,5))                                                           '方位
'             Label2(6).Caption = Val(Mid(tmpStr,j + 24,4))                                                           '状态
'        End If
'
'        '$GPZDA,055217,20,05,2011,-8,0\CR\LF
'        k = InStr(1,"$GPZDA",vbTextCompare)
'        If k Then
'             Label2(4).Caption = Mid(tmpStr,k + 20,4) & "-" & Mid(tmpStr,k + 17,2) & "-" & Mid(tmpStr,k + 14,2)  '日期
'        End If
'   End If
'
'     If UCase(Mode) = "SAMYANG" Then
'        i = InStr(1,vbTextCompare)
'        If i Then
'            LblInfo(0).Caption = Val(Mid(tmpStr,i + 19,9))  '经度
'            LblInfo(1).Caption = Mid(tmpStr,10)      '纬度
'            LblInfo(2).Caption = Val(Mid(tmpStr,i + 44,4))  '速度
'            LblInfo(3).Caption = Mid(tmpStr,2)
'        End If
'
'        j = InStr(1,vbTextCompare)
'        If j Then
'             Label2(7).Caption = Mid(tmpStr,j + 17,4) ' Val(Mid(tmpStr,j + 12,4))
'             Label2(6).Caption = Mid(tmpStr,4)
'        End If
'
'        k = InStr(1,2)
'        End If
'   End If
'
'    '$GPVTG,153.6,11.9,22.0,K,A*05
'    '$GPVTG,147.8,11.8,21.9,124.9,11.4,21.1,168.7,8.0,14.8,A*30
'    '$GPVTG,166.7,9.4,17.4,A*34
'    '$GPVTG,88.0,A*02
'    '$GPVTG,251.7,0.1,0.2,A*0F
'    '$GPVTG,173.8,1.3,2.4,A*04
'
'   If UCase(Mode) = "GP90" Then
'        Shape1.FillColor = vbGreen
'
'
'        i = InStr(1,"$GPGLL",9))
'            LblInfo(1).Caption = Mid(tmpStr,8)
'            LblInfo(3).Caption = Mid(tmpStr,i + 32,6)
'
'        End If
'
'        j = InStr(1,vbTextCompare)
'        If j Then
'            Dim TmpV As String
'            TmpV = Mid(tmpStr,j + 6,28)
'
'         '   Debug.Print TmpV
'            Dim m As Integer
'            Dim n As Integer
'           ' Dim k As Integer
'
'            m = InStr(1,TmpV,"N")
'            n = InStr(1,"K")
'
'            k = n - m - 3
'
'           ' Debug.Print Mid(TmpV,m + 2,k)
'            LblInfo(2).Caption = Val(Mid(TmpV,k))         '速度
'             'LblInfo(2).Caption = Val(Mid(tmpStr,4))    '速度
'
'            m = InStr(1,"T")
'            n = InStr(1,"M")
'            k = n - m - 3
'            Label2(7).Caption = Val(Mid(TmpV,k))          '方位
'
'           ' Label2(7).Caption = Val(Mid(tmpStr,5))
'
'           '  SaveInfo tmpStr
'        End If
'
'        k = InStr(1,k + 23,2)
'        End If
'        l = InStr(1,"$GPRMB",vbTextCompare)
'        Label2(6).Caption = Val(Mid(tmpStr,l + 56,3))
'   End If

猜你在找的VB相关文章