Musaran Cerveaulté | Tiens, j'avais tenté de modifier cette chaîne... certains paramètres évoluent bizarrement.
Leur valeur interne n'est pas celle affichée par les contrôles. Peut-être même qu'il y a des flottants ?
Vu qu'elle est de toutre façons si longue, ils auraient pu mettre de l'hexadécimal !
Pour réencoder, on fait l'inverse: TextIn = ...
TextOut = ""
LenTextIn = Len(TextIn)
pos = 1
While pos < LenTextIn
TextInChunk = Mid(TextIn, pos, 6)
Select Case TextInChunk
Case "000000": Value = "A"
Case "000001": Value = "B"
Case "000010": Value = "C"
Case "000011": Value = "D"
Case "000100": Value = "E"
Case "000101": Value = "F"
Case "000110": Value = "G"
Case "000111": Value = "H"
Case "001000": Value = "I"
Case "001001": Value = "J"
Case "001010": Value = "K"
Case "001011": Value = "L"
Case "001100": Value = "M"
Case "001101": Value = "N"
Case "001110": Value = "O"
Case "001111": Value = "P"
Case "010000": Value = "Q"
Case "010001": Value = "R"
Case "010010": Value = "S"
Case "010011": Value = "T"
Case "010100": Value = "U"
Case "010101": Value = "V"
Case "010110": Value = "W"
Case "010111": Value = "X"
Case "011000": Value = "Y"
Case "011001": Value = "Z"
Case "011010": Value = "a"
Case "011011": Value = "b"
Case "011100": Value = "c"
Case "011101": Value = "d"
Case "011110": Value = "e"
Case "011111": Value = "f"
Case "100000": Value = "g"
Case "100001": Value = "h"
Case "100010": Value = "i"
Case "100011": Value = "j"
Case "100100": Value = "k"
Case "100101": Value = "l"
Case "100110": Value = "m"
Case "100111": Value = "n"
Case "101000": Value = "o"
Case "101001": Value = "p"
Case "101010": Value = "q"
Case "101011": Value = "r"
Case "101100": Value = "s"
Case "101101": Value = "t"
Case "101110": Value = "u"
Case "101111": Value = "v"
Case "110000": Value = "w"
Case "110001": Value = "x"
Case "110010": Value = "y"
Case "110011": Value = "z"
Case "110100": Value = "0"
Case "110101": Value = "1"
Case "110110": Value = "2"
Case "110111": Value = "3"
Case "111000": Value = "4"
Case "111001": Value = "5"
Case "111010": Value = "6"
Case "111011": Value = "7"
Case "111100": Value = "8"
Case "111101": Value = "9"
Case "111110": Value = "+"
Case "111111": Value = "/"
End Select
TextOut = TextOut & Value
pos = pos + 6
Loop |
Mais:
D'une part on peut peut-être faire mieux.
D'autre part il te faudra sûrement des fonctions de conversion entier<->chaîne binaire.
Voici les miennes en VB6: Rem Convertit une chaîne de 0 et de 1 en sa valeur binaire.
Rem Maximum 32 chiffres, chaîne vide = 0.
Function StrBin2Val(StrBin As String) As Long
Dim Pos As Integer
Dim Weight As Long
StrBin2Val = 0
Pos = Len(StrBin)
Weight = 1: Rem Valeur du bit en Pos dans StrBin
If Pos > 32 Then Error 65535: Rem plus de 32 chiffres binaires !
Do
Select Case Mid$(StrBin, Pos, 1)
Case "0":
Case "1": StrBin2Val = StrBin2Val + Weight
Case Else: Error 65535Rem Pas un chiffre binaire !
End Select
If Pos <= 1 Then Exit Do
Rem préparer le bit suivant
Pos = Pos - 1
If Weight = 1073741824 Then
Weight = -2147483648#: Rem *2 donnerait un overflow
Else
Weight = Weight * 2
End If
Loop
End Function |
Rem Convertit une valeur binaire 32 bits en chaîne de 32 0 et/ou 1.
Function Val2StrBin(ByVal Val As Long) As String
Dim Count As Integer
Val2StrBin = ""
For Count = 1 To 32
Val2StrBin = IIf(Val Mod 2 = 1, "1", "0" ) & Val2StrBin
Rem Val2StrBin = IIf(Val Mod Weight > 0, "1", "0" ) & Val2StrBin
Rem Val = Val \ Weight * Weight
If Val < 0 Then
Val = Val + 2147483648#: Rem Gestion du bit de signe
Else
Val = Val \ 2
End If
Next
End Function |
---------------
Bricocheap: Montage de ventilo sur paté de mastic silicone
|