String in Hexadezimal

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
Bisonte
Beiträge: 2468
Registriert: 01.04.2007 20:18

Beitrag von Bisonte »

Oder man macht es sich opalike ;) und installiert die droopy userlib ;)
Hex2Dec(HexNumber.s)

Description :

Converts a Hex value ( as String ) to a Decimal value ( as Long )

Example :

Hex2Dec("FF")
PureBasic 6.21 (Windows x86/x64) | Windows11 Pro x64 | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | GeForce RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
Benutzeravatar
jear
Beiträge: 288
Registriert: 17.10.2004 01:59
Wohnort: Ammerland

Beitrag von jear »

auch "opalike": :D

Code: Alles auswählen

;- Umwandlung HEX-String zu Quad (dezimal)
Procedure.q Hex2Dec(HexValue.s) 
  Protected x.s = LCase(HexValue)
  Protected l.l = Len(x)
  Protected i.l, n.l, result.q
  For i = 1 To l
    result * 16
    n = FindString("0123456789abcdef", Mid(x, i, 1), 1) -1            
    result + n    
  Next i 
  ProcedureReturn result 
EndProcedure
Man ist nie zu alt zum lernen, auch wenn man dabei manchmal alt aussieht!
Antworten