QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: TheGuardHQ on February 26, 2020, 09:43:04 am
-
Hi all!
I'm looking for something comparable to the function "CByte" from VB.
But actually I am concerned with writing a CRC calculation for the MODBUS protocol:
Public Function crc(Framestr As String) As Byte
Dim count As Integer
Dim dummy As Byte
Do While (count < Len(Framestr))
count = count + 1
dummy = Asc(Mid(Framestr, count)) * 2 And &HFF
crc = crc Xor CByte(Asc(Mid(Framestr, count)) Xor dummy)
Loop
End Function
Did someone else ever have the same prolem and have you already written a function?