Conversion d'un grand nombre hexadécimal.

pan european

XLDnaute Nouveau
Bonjour
Je dois convertir un nombre hexadécimal en binaire or, si le nombre dépasse 511 ou #1FF, il n’est plus converti par la fonction HEXBIN (ou DECBIN).
Mon problème est que je dois convertir un nombre hexa à 6 digits (Ex : 3949ED).
Comment puis-je procéder ?
Pour pallier, j’ai scindé le nombre hexa en trois groupes (Ex 39 49 ED) avec la fonction STXT, fait la conversion en binaire (HEXBIN) puis recollé les trois nombre en un avec la fonction CONCATENER.
J’arrive au bon résultat mais si quelqu’un avait le moyen de convertir un grand nombre hexa, ce serait bien.
Merci coop.
 

pierrejean

XLDnaute Barbatruc
Re : Conversion d'un grand nombre hexadécimal.

Bonjour pan european
Bonjour tbft (bonne idée)
Salut hasco

Une fonction personnalisée
Peut-etre un zeste cappilotractée mais puisque je l'ai faite !!!
 

Pièces jointes

  • Hexa_binaire.zip
    9.3 KB · Affichages: 195

tbft

XLDnaute Accro
Re : Conversion d'un grand nombre hexadécimal.

Bonjour Pierrejean

Je me suis permis de récupérer le fichier magique.
Je pense le modifier pour faire deux ou trois autres conversions à cinq pattes
Merci encore pour l'aide..
 

ROGER2327

XLDnaute Barbatruc
Re : Conversion d'un grand nombre hexadécimal.

Bonsoir à tous
Deux autres solutions :
Code:
[COLOR="DarkSlateGray"][B]Function hex_bin1$(h)
Dim y, i&
   h = UCase("" & h)
   y = Array("0123456789ABCDEF", "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111")
   On Error GoTo E
   For i = Len(h) To 1 Step -1
      h = Left$(h, i - 1) & Replace(h, Mid$(h, i, 1), y(WorksheetFunction.Find(Mid$(h, i, 1), y(0))), i, 1)
   Next i
   hex_bin1 = h
E: On Error GoTo 0
End Function

Function hex_bin2$(h)
Dim y, i&
   h = UCase("" & h)
   y = Array("0123456789ABCDEF", "0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111")
   On Error GoTo E
   For i = Len(h) To 1 Step -1
      h = Left$(h, i - 1) & Replace(h, Mid$(h, i, 1), y(WorksheetFunction.Find(Mid$(h, i, 1), y(0))), i, 1)
   Next i
   For i = 1 To Len(h) - 1
      If Left$(h, 1) = "0" Then h = Right$(h, Len(h) - 1) Else Exit For
   Next i
   hex_bin2 = h
E: On Error GoTo 0
End Function[/B][/COLOR]
=hex_bin1("3949ED") renvoie "001110010100100111101101".
=hex_bin2("3949ED") renvoie "1110010100100111101101".
ROGER2327
#4011


Samedi 14 Phalle 137 (Bataille de Morsang, ST)
7 Fructidor An CCXVIII
2010-W34-2T21:48:54Z
 

Statistiques des forums

Discussions
312 485
Messages
2 088 802
Membres
103 971
dernier inscrit
abdazee