Hex 2 Num

BlitzPlus Forums/BlitzPlus Programming/Hex 2 Num

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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]