在 WM 平台上开发 GPS 导航系统
2010-02-21 22:52:00 来源:WEB开发网60 Dim Today As DateTime = System.DateTime.Now.ToUniversalTime
61 Dim SatelliteTime As New System.DateTime(Today.Year, Today.Month, _
62 Today.Day, UtcHours, UtcMinutes, UtcSeconds, UtcMilliseconds)
63 ' Notify of the new time, adjusted to the local time zone
64 RaiseEvent DateTimeChanged(SatelliteTime.ToLocalTime)
65 End If
66 ' Indicate that the sentence was recognized
67 Return True
68 End Function
69 ' Returns True if a sentence's checksum matches the calculated checksum
70 Public Function IsValid(ByVal sentence As String) As Boolean
71 ' Compare the characters after the asterisk to the calculation
72 Return sentence.Substring(sentence.IndexOf("*") + 1) = _
73 GetChecksum(sentence)
74 End Function
75 ' Calculates the checksum for a sentence
76 Public Function GetChecksum(ByVal sentence As String) As String
77 ' Loop through all chars to get a checksum
78 Dim Character As Char
79 Dim Checksum As Integer
80 For Each Character In sentence
81 Select Case Character
82 Case "$"c
83 ' Ignore the dollar sign
84 Case "*"c
85 ' Stop processing before the asterisk
86 Exit For
87 Case Else
88 ' Is this the first value for the checksum?
89 If Checksum = 0 Then
90 ' Yes. Set the checksum to the value
91 Checksum = Convert.ToByte(Character)
92 Else
93 ' No. XOR the checksum with this character's value
94 Checksum = Checksum Xor Convert.ToByte(Character)
95 End If
96 End Select
97 Next
98 ' Return the checksum formatted as a two-character hexadecimal
99 Return Checksum.ToString("X2")
100 End Function
- ››开发Android 日历教程
- ››开发学院总结 Win 8实用技巧大全
- ››开发学院原创教程:把win8的IE10放桌面上方法(非...
- ››开发者眼中的Windows Phone和Android
- ››开发学院教你用SQL 语句最快速清空MySQL 数据表的...
- ››WM 无法连接到win 7及webservice的异类原因
- ››开发一个自己的HTML在线编辑器(一)
- ››开发一个自己的HTML在线编辑器(二)
- ››开发者在App Store上赚的钱比在Android Market上多...
- ››开发者应深入学习的10个Android开源应用项目
- ››WM/WP上最完美的背光控制软件
- ››WM性能优化的一些经验
更多精彩
赞助商链接