Code archives/Algorithms/Hex$ to Decimal

This code has been declared by its author to be Public Domain code.

Download source code

Hex$ to Decimal by Cybersed
(Posted 22 years ago)
This little Function will convert a string containing an hex value and return a decimal integer. Hex values do not need to be specially formatted. Ex: FF, fF, 0xff are OK. Non hex characters are simply ignored.
Function Dec(h$)

	t2$=Upper$(Trim$(h$))
	d=0
	For z=1 To Len(t2$)
		i=Instr("0123456789ABCDEF",Mid$(t2$,z,1))
		If i>0 Then d=d*16+i-1
	Next

	Return d

End Function

Comments

GG
(Posted 20 years ago)
You saved me an hour of work with something very effective, thanks you a lot

Code Archives Forum