Author Topic: VB-Function "CByte"  (Read 2354 times)

0 Members and 1 Guest are viewing this topic.

Offline TheGuardHQ

  • Newbie
  • Posts: 6
    • View Profile
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:

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?