WEB开发网
开发学院手机开发Windows Mobile 开发 在 WM 平台上开发 GPS 导航系统 阅读

在 WM 平台上开发 GPS 导航系统

 2010-02-21 22:52:00 来源:WEB开发网   
核心提示:minutes39 Latitude = Latitude & Words(4) ' Append the hemisphere40 Dim Longitude As String = Words(5).Substring(0, 3) & "°" ' Append hours41 L
minutes

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

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:WM 平台 开发

编辑录入:coldstar [复制链接] [打 印]
赞助商链接