在 WM 平台上开发 GPS 导航系统
2010-02-21 22:52:00 来源:WEB开发网39 Latitude = Latitude & Words(4) ' Append the hemisphere
40 Dim Longitude As String = Words(5).Substring(0, 3) & "°" ' Append hours
41 Longitude = Longitude & Words(5).Substring(3) & """" ' Append minutes
42 Longitude = Longitude & Words(6) ' Append the hemisphere
43 ' Notify the calling application of the change
44 RaiseEvent PositionReceived(Latitude, Longitude)
45 End If
46 ' Indicate that the sentence was recognized
47 Return True
48 End Function
49 ' Returns True if a sentence's checksum matches the calculated checksum
50 Public Function IsValid(ByVal sentence As String) As Boolean
51 ' Compare the characters after the asterisk to the calculation
52 Return sentence.Substring(sentence.IndexOf("*") + 1) = GetChecksum(sentence)
53 End Function
54 ' Calculates the checksum for a sentence
55 Public Function GetChecksum(ByVal sentence As String) As String
56 ' Loop through all chars to get a checksum
57 Dim Character As Char
58 Dim Checksum As Integer
59 For Each Character In sentence
60 Select Case Character
61 Case "$"c
62 ' Ignore the dollar sign
63 Case "*"c
64 ' Stop processing before the asterisk
65 Exit For
66 Case Else
67 ' Is this the first value for the checksum?
68 If Checksum = 0 Then
69 ' Yes. Set the checksum to the value
70 Checksum = Convert.ToByte(Character)
71 Else
72 ' No. XOR the checksum with this character's value
73 Checksum = Checksum Xor Convert.ToByte(Character)
74 End If
75 End Select
76 Next
77 ' Return the checksum formatted as a two-character hexadecimal
- ››开发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性能优化的一些经验
更多精彩
赞助商链接