Access the answers to your technology questions today.
Subscribe Now
30-day free trial. Register in 60 seconds.
What Makes Experts Exchange Unique?
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.
Try it out and discover for yourself.
Subscribe Now
30-day free trial. Register in 60 seconds.
Join the Community
Give a Little. Get a Lot.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Join the Community
by: jaime_olivaresPosted on 2005-05-04 at 19:06:17ID: 13932412
Function GetChecksum(ByVal sentence As String) As String
' Loop through all chars to get a checksum
Dim Character As Char
Dim Checksum As Integer
Dim I as Integer
For I = 1 to Len(sentence)
Character = Mid(sentence, I, 1)
Select Case Character
Case "$"
' Ignore the dollar sign
Case "*"
' Stop processing before the asterisk
Exit For
Case Else
' Is this the first value for the checksum?
If Checksum = 0 Then
' Yes. Set the checksum to the value
Checksum = Asc(Character)
Else
' No. XOR the checksum with this character's value
Checksum = Checksum Xor Asc(Character)
End If
End Select
Next
' Return the checksum formatted as a two-character hexadecimal
GetChecksum = Hex(CheckSum)
If Len(CheckSum)<2
CheckSum = "0" & CheckSum
End If
End Function