Sub cmd1(value As String) As String
Try
Log(value)
Dim A As String
Dim Var2 As String
Dim Var4 As String
Dim Var5 As String
Dim bc As ByteConverter
A=value.Length
'a = Hex(a + 2)
'A=Bit.ToHexString(A+2)
A = bc.HexFromBytes(Array As Byte(Bit.ParseInt(A+2, 2)))
A=A.ToUpperCase
'If Len(a) < 2 Then
If A.Length<2 Then
Var2 = "0" & A & value
Else
Var2 = A & value
End If
'a = Len(Var2)
A=Var2.Length
'Dim b As Integer
'Dim num As Integer
Dim b As Int
Dim num As Int
For b = 1 To A
'num=num+asc(Mid(Var2, b, 1)))
num = num + Asc(Var2.CharAt(b-1))
'Next b
Next
Var4 = num Mod 256
'Var5 = Hex(CByte(((Not Val(Var4)) + 1) AND 255))
Dim tempByte As Byte
tempByte=Bit.And ((Bit.Not(Var4)+1),255)
'Var5 = Bit.ToHexString (tempByte)
Var5 = bc.HexFromBytes(Array As Byte(Bit.ParseInt(tempByte, 2)))
Var5=Var5.SubString (Var5.Length -2)
'While Len(Var5) < 2
Do While Var5.Length < 2
Var5 = "0" & Var5
'Wend
Loop
'CalculateCRC = Var2 & Var5
Dim tempCRC As String
tempCRC=Var2 & Var5.Touppercase
Return tempCRC
Catch
Log(LastException.Description)
End Try
End Sub