Convert Decimal value to Hexadecimal string

Posted on 2006-07-24
Last Modified: 2010-04-23
Can anyone tell me a neat way to convert a decimal value to a Hexadecimal string?


for i as integer=0 to 3000

(Convert i to Hexidecimal string)


Question by:IAJWDDIY
  • 2
LVL 17

Accepted Solution

ZeonFlash earned 500 total points
ID: 17169434
for i as integer=0 to 3000

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


LVL 35

Expert Comment

ID: 17169528
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
LVL 35

Expert Comment

ID: 17169537
for i as integer=0 to 3000

Author Comment

ID: 17170115
Thank you, just the job!

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question