1
QB64 Discussion / VB-Function "CByte"
« 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:
Did someone else ever have the same prolem and have you already written a function?
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:
Quote
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?