CURTISBEEF
New member
OK I have been programming for the 633 for a little while but i have run into a brick wall because the CRC code im using does not support the use of zeros up untill now i have just worked around it
the CRC module im using is this
http://www.iland.net/~jhaase/vbcrc/
I really need help im making a big program and it requires the use of all the 633's functions
the CRC module im using is this
http://www.iland.net/~jhaase/vbcrc/
I really need help im making a big program and it requires the use of all the 633's functions
Code:
Public Function CalculateCRC(oString As String)
Dim CRC As String
CRC = Main.VbCrC1.CrcCalc(oString, CCITT)
CRC = Dec2Bin(CRC)
CRC = Format(CRC, "0000000000000000")
crc2 = Left(CRC, 8)
crc1 = Right(CRC, 8)
crc1 = Bin2Dec(Format(crc1, "00000000"))
crc2 = Bin2Dec(Format(crc2, "00000000"))
CalculateCRC = Chr(crc1) & Chr(crc2)
End Function
Public Function Txt2Dec(Char As String) As Long
Dim GetAscii&
For GetAscii& = 0 To 255
If Mid(Char$, 1, 1) = Chr(GetAscii) Then
Txt2Dec = GetAscii
Exit Function
End If
Next GetAscii&
End Function
Public Function Txt2Bin(StringT As String) As String
Dim Ascii, FinalBinary$, GetNum&
FinalBinary$ = ""
For GetNum& = 1 To Len(StringT$)
Ascii = Txt2Dec(Mid(StringT$, GetNum, 1))
' 128
If Ascii >= 128 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 128
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 64
If Ascii >= 64 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 64
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 32
If Ascii >= 32 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 32
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 16
If Ascii >= 16 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 16
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 8
If Ascii >= 8 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 8
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 4
If Ascii >= 4 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 4
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 2
If Ascii >= 2 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 2
Else
FinalBinary$ = FinalBinary$ & "0"
End If
' 1
If Ascii >= 1 Then
FinalBinary$ = FinalBinary$ & "1"
Ascii = Ascii - 1
Else
FinalBinary$ = FinalBinary$ & "0"
End If
If Mid(StringT$, GetNum + 1, 1) = Chr(32) Then
FinalBinary$ = FinalBinary$ '& " "
Else
FinalBinary$ = FinalBinary$ '& Chr(32)
End If
Next GetNum&
Txt2Bin$ = FinalBinary$
End Function
Public Function Bin2Dec(oString As String)
Dim NewText As String
Dim i As Integer, count As Integer, BinaryString As String
Dim n As Integer, Character As String, Value As Integer
Dim CompletedString As String
NewText = Replace(oString, Chr(32), "")
For i = 1 To Len(NewText)
BinaryString = BinaryString & Mid(NewText, i, 1)
count = count + 1
If count = 8 Then
For n = 1 To Len(BinaryString)
Character = Mid(BinaryString, n, 1)
If Val(Character) = 1 Then
If n = 1 Then
Value = Value + 128
ElseIf n = 2 Then
Value = Value + 64
ElseIf n = 3 Then
Value = Value + 32
ElseIf n = 4 Then
Value = Value + 16
ElseIf n = 5 Then
Value = Value + 8
ElseIf n = 6 Then
Value = Value + 4
ElseIf n = 7 Then
Value = Value + 2
ElseIf n = 8 Then
Value = Value + 1
End If
End If
Next n
CompletedString = CompletedString & Value & " "
Value = 0
count = 0
BinaryString = ""
End If
Next i
Bin2Dec = CompletedString
CompletedString = ""
End Function
Public Function Dec2Bin(mynum As String) As String
Dim loopcounter As Integer
If mynum >= 2 ^ 31 Then
Dec2Bin = "Too big"
Exit Function
End If
Do
If (mynum And 2 ^ loopcounter) = 2 ^ loopcounter Then
Dec2Bin = "1" & Dec2Bin
Else
Dec2Bin = "0" & Dec2Bin
End If
loopcounter = loopcounter + 1
Loop Until 2 ^ loopcounter > mynum
End Function
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.