Hex 2 Num

BlitzPlus Forums/BlitzPlus Programming/Hex 2 Num

WillKoh(Posted 2004) [#1]
Can someone write a func that converts hex to a regular number, esp., if possible, one that works with those rather strange hex-values used in VisualBasic colors, (from numb to vb-hex too, please)..


Snarty(Posted 2004) [#2]
Hi had this laying around, might be of some use. Has my strange coding style written all over it. There is probably a better way.

[Code]Function Dec(HexVal$)

For t=Len(HexVal) To 1 Step -1
chk$=Mid(HexVal,t,1)
If Chk$<>"0"
Val=chk$
If Val=0
Val=Asc(Chk)-55
EndIf
Else
Val=0
EndIf
If Count=0
Decimal=Decimal+Val
Else
Decimal=Decimal+(Val*(16^Count))
EndIf
Count=Count+1
Next
Return Decimal

End Function[/code]


WillKoh(Posted 2004) [#3]
OK.. Thanx.


Mr Brine(Posted 2004) [#4]
did u know you can use hex values in blitz ie:

local = $ff

v is now equal to 255