• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

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

0
IAJWDDIY
Asked:
IAJWDDIY
  • 2
1 Solution
 
ZeonFlashCommented:
for i as integer=0 to 3000

strHex = String.Format("{0:x2}", i)

Next

0
 
YZlatCommented:
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
0
 
YZlatCommented:
for i as integer=0 to 3000
   DecToHex(i)
Next
0
 
IAJWDDIYAuthor Commented:
Thank you, just the job!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now