CONVERSION D'UN NOMBRE PACKÉ ("PACKED NUMBER") EN NOMBRE DÉCIMAL

Adn56 Messages postés 1172 Date d'inscription jeudi 24 mai 2007 Statut Membre Dernière intervention 28 septembre 2013 - 24 févr. 2010 à 18:41
cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 - 24 févr. 2010 à 21:55
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/51343-conversion-d-un-nombre-packe-packed-number-en-nombre-decimal

cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 16
24 févr. 2010 à 21:55
Y'a plus simple (code à vérifier mais il devrait fonctionner) :

Public Function UnpackNum(theAmt As String) As Double
Dim thelast As String, theFrnt As String
thelast = Right(Trim(theAmt), 1)
theFrnt = Mid$(theAmt, 1, Len(theAmt) - 1) If thelast "{" Or thelast "}" Then thelast = "0"
If Asc(thelast) > 73 And Asc(thelast) < 83 Then thelast = Chr(Asc(thelast) - 25)
If Asc(thelast) > 64 And Asc(thelast) < 74 Then thelast = Chr(Asc(thelast) - 16)
UnpackNum = Val(theFrnt & thelast) / 100 If thelast "}" Or (Asc(thelast) > 73 And Asc(thelast) < 83) Then UnpackNum -UnpackNum
End Function
Adn56 Messages postés 1172 Date d'inscription jeudi 24 mai 2007 Statut Membre Dernière intervention 28 septembre 2013 1
24 févr. 2010 à 18:41
doublon ^^