Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • 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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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