Solved

Convert Decimal value to Hexadecimal string

Posted on 2006-07-24
4
324 Views
Last Modified: 2010-04-23
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
Comment
Question by:IAJWDDIY
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
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

by:YZlat
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

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

Author Comment

by:IAJWDDIY
ID: 17170115
Thank you, just the job!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now