正文

VB GPS 编程源程序2005-09-22 21:02:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/5128.html

分享到:

VB GPS 编程源程序
gisant 发表于 2005-3-18 9:31:56

Private Sub GPSComm_OnComm()
    On Error GoTo ErrHdl

    Dim oData As String
    Dim aData() As String
    Dim aDataLen As Integer
    Dim counter1 As Integer
    
    oData = CStr(GPSComm.Input)
    
    If Mid(oData, 1, 1) <> "$" Then
        Exit Sub
    End If
    
    aData = Split(oData, vbCrLf)
    aDataLen = 8
    
    For counter1 = 1 To aDataLen Step 1
      If Len(aData(counter1)) < 6 Then
        Exit For
      End If
      If Mid(aData(counter1), 2, 5) = "GPRMC" Then
        Dim gprmc() As String
        Dim utime As Date
        Dim status As Boolean
        Dim Latitude As Double
        Dim Longitude As Double
        Dim Speed As Double
        Dim Delta As Double
        
        gprmc = Split(aData(counter1), ",")
        
        Dim hour As String
        Dim minute As String
        Dim second As String
        
        hour = Mid(gprmc(1), 1, 2)
        minute = Mid(gprmc(1), 3, 2)
        second = Mid(gprmc(1), 5, 2)

        utime = Timevalue(hour & ":" & minute & ":" & second)
        
        If gprmc(2) = "A" Then
            status = True
        Else
            status = False
            Exit Sub
        End If
        
        Latitude = CDbl(gprmc(3)) / 100
        Longitude = CDbl(gprmc(5)) / 100
                                        
'        '>分到度
'        Dim PartA As String, PartB As String, DotPos As Integer, DblA As Double, DblB As Double
'        'Dim NewLon As Double, NewLat As Double
'        PartA = CStr(Longitude)
'        DotPos = InStr(PartA, ".")
'
'        PartB = Mid(PartA, DotPos + 1, Len(PartA) - DotPos)
'        PartA = Mid(PartA, 1, DotPos - 1)
'
'        DblA = CDbl(PartA)
'        DblB = CDbl(Mid(PartB, 1, 2) & "." & Mid(PartB, 3, Len(PartB) - 2) & "0") / 60
'
'        Longitude = DblA + DblB
'
'        PartA = CStr(Latitude)
'        DotPos = InStr(PartA, ".")
'        PartB = Mid(PartA, DotPos + 1, Len(PartA) - DotPos)
'        PartA = Mid(PartA, 1, DotPos - 1)
'        DblA = CDbl(PartA)
'        DblB = CDbl(Mid(PartB, 1, 2) & "." & Mid(PartB, 3, Len(PartB) - 2) & "0") / 60
'
'        Latitude = DblA + DblB
'        '<分到度
'
        
        Speed = CDbl(gprmc(7)) * 1.609
        Delta = CDbl(gprmc(8))
        
        Exit For
      End If
    Next

阅读(2389) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册