Solved

Convert Decimal value to Hexadecimal string

Posted on 2006-07-24
4
342 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

19 Experts available now in Live!

Get 1:1 Help Now