- Function SHL(x As Byte, i As Integer) As Byte ' shl(octet ,nombre de décalage)
- SHL = ((x * 2 ^ i) And 255)
- End Function
-
-
- Function SHR(y As Byte, k As Integer) As Byte ' shr(octet ,nombre de décalage)
- SHR = CByte(Int(y / (2 ^ k)))
- End Function
-
- Function Dec2Hex(dec As Long) As String
- Dec2Hex = hex(dec)
- End Function
-
- Function Hex2Dec(hex As String) As Long
- Hex2Dec = Val("&h" & hex)
- End Function
- Function Hex2Bin(hex As String) As String
- Dim i As Byte
- Dim resultat As String
- For i = 1 To Len(hex)
- Select Case Mid(hex, i, 1)
- Case "0": resultat = resultat & "0000"
- Case "1": resultat = resultat & "0001"
- Case "2": resultat = resultat & "0010"
- Case "3": resultat = resultat & "0011"
- Case "4": resultat = resultat & "0100"
- Case "5": resultat = resultat & "0101"
- Case "6": resultat = resultat & "0110"
- Case "7": resultat = resultat & "0111"
- Case "8": resultat = resultat & "1000"
- Case "9": resultat = resultat & "1001"
- Case "A": resultat = resultat & "1010"
- Case "B": resultat = resultat & "1011"
- Case "C": resultat = resultat & "1100"
- Case "D": resultat = resultat & "1101"
- Case "E": resultat = resultat & "1110"
- Case "F": resultat = resultat & "1111"
- End Select
- Next i
- Hex2Bin = resultat
- End Function
- Function Bin2Dec(bin As String) As String
- Dim i As Byte
- Dim resultat As Long
- resultat = 0
- For i = 1 To Len(bin)
- If Mid(bin, Len(bin) - i + 1, 1) = 1 Then
- resultat = resultat + 2 ^ (i - 1)
- End If
- Next i
- Bin2Dec = resultat
- End Function
Function SHL(x As Byte, i As Integer) As Byte ' shl(octet ,nombre de décalage)
SHL = ((x * 2 ^ i) And 255)
End Function
Function SHR(y As Byte, k As Integer) As Byte ' shr(octet ,nombre de décalage)
SHR = CByte(Int(y / (2 ^ k)))
End Function
Function Dec2Hex(dec As Long) As String
Dec2Hex = hex(dec)
End Function
Function Hex2Dec(hex As String) As Long
Hex2Dec = Val("&h" & hex)
End Function
Function Hex2Bin(hex As String) As String
Dim i As Byte
Dim resultat As String
For i = 1 To Len(hex)
Select Case Mid(hex, i, 1)
Case "0": resultat = resultat & "0000"
Case "1": resultat = resultat & "0001"
Case "2": resultat = resultat & "0010"
Case "3": resultat = resultat & "0011"
Case "4": resultat = resultat & "0100"
Case "5": resultat = resultat & "0101"
Case "6": resultat = resultat & "0110"
Case "7": resultat = resultat & "0111"
Case "8": resultat = resultat & "1000"
Case "9": resultat = resultat & "1001"
Case "A": resultat = resultat & "1010"
Case "B": resultat = resultat & "1011"
Case "C": resultat = resultat & "1100"
Case "D": resultat = resultat & "1101"
Case "E": resultat = resultat & "1110"
Case "F": resultat = resultat & "1111"
End Select
Next i
Hex2Bin = resultat
End Function
Function Bin2Dec(bin As String) As String
Dim i As Byte
Dim resultat As Long
resultat = 0
For i = 1 To Len(bin)
If Mid(bin, Len(bin) - i + 1, 1) = 1 Then
resultat = resultat + 2 ^ (i - 1)
End If
Next i
Bin2Dec = resultat
End Function