Solved

# Convert Decimal value to Hexadecimal string

Posted on 2006-07-24
324 Views
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
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)

Next

0

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
0

LVL 35

Expert Comment

ID: 17169537
for i as integer=0 to 3000
DecToHex(i)
Next
0

Author Comment

ID: 17170115
Thank you, just the job!
0

## Featured Post

### Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…