Convert hex value to a decimal value in VB6

Viewed 48945

How can I convert a hex value to a decimal value in VB6?

I'm trying just to see if this works:

Dim hexVal as string
hexVal = "#7B19AB"
clng("&H" & hexVal)

However, I'm getting "Type MisMatch" error.

8 Answers

Be very carful.

Dim hexVal as string
hexVal = "FFFF"
clng("&H" & hexVal)

will return a value of -1 because it thinks your HEX value is signed. See what happens with F00A, again it thinks its signed.

Replace the Clng with ABS.

Related