Link to home
Start Free TrialLog in
Avatar of IAJWDDIY
IAJWDDIY

asked on

Convert Decimal value to Hexadecimal string

Can anyone tell me a neat way to convert a decimal value to a Hexadecimal string?

e.g

for i as integer=0 to 3000

(Convert i to Hexidecimal string)

Next

ASKER CERTIFIED SOLUTION
Avatar of ZeonFlash
ZeonFlash

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of YZlat
Function DecToHex(ByVal value As Long) As String
        Dim res As String = Convert.ToString(value, 16).ToUpper()
        Return res
    End Function

and to convert back from hex to decimal, use:

 Function HexToDec(ByVal value As String) As String
        Return Convert.ToInt64(value, 16)
    End Function
for i as integer=0 to 3000
   DecToHex(i)
Next
Avatar of IAJWDDIY
IAJWDDIY

ASKER

Thank you, just the job!