I'm currently looking for the method how to calculate checksum, can I know is that my coding method is correct? the result that I calculate compare with the Windows Calculator is different. please give some advice. thx


Public Function CalcLRC(ByVal StringToLRC As String) As String
' Calculate command checksum before sent to reader

Dim chksum, ltxt, i%

chksum = "&H" & "0"

ltxt = Len(Trim(StringToLRC))
For i% = 1 To ltxt Step 2
chksum = ("&H" & Mid(StringToLRC, i, 2) Xor chksum)
Next i
chksum = Hex(chksum)
If Len(chksum) = 1 Then chksum = "0" & chksum

CalcLRC = chksum

End Function