Click here to Skip to main content
12,702,791 members (32,371 online)
Click here to Skip to main content
Add your own
alternative version


32 bookmarked

Hex Converter

, 18 Jun 2003
Rate this:
Please Sign up or sign in to vote.
This article is about a program which helps you convert numeric value from decimal to hexadecimal representation and vice versa.


This article is about how you would go about converting numeric values to hexadecimal and vice versa. The main reason why I did this program is to help me to cheat when playing computer games, mainly role-playing ones cos I normally need to find the correct hex data in those save game file and furthermore I do not have a good hex editor to help me do those conversion. :)

Using the code

The main code used for the conversion are from the System.Convert class. Below is the code that is used to convert a string to unsigned integer while checking for overflow, and then convert it to hexadecimal format before showing it as a string in a text box.

// To hold our converted unsigned integer32 value
uint uiDecimal = 0;

    // Convert text string to unsigned integer
    uiDecimal = checked((uint)System.Convert.ToUInt32(tbDecimal.Text));

catch (System.OverflowException exception) 
    // Show overflow message and return
    tbHex.Text = "Overflow";

// Format unsigned integer value to hex and show in another textbox
tbHex.Text = String.Format("{0:x2}", uiDecimal);

and vice versa

// To hold our converted unsigned integer32 value
uint uiHex = 0;

    // Convert hex string to unsigned integer
    uiHex = System.Convert.ToUInt32(tbHex.Text, 16);

catch (System.OverflowException exception) 
    // Show overflow message and return
    tbDecimal.Text = "Overflow";

// Format it and show as a string
tbDecimal.Text = uiHex.ToString();


This is my first attempt at C# and WinForms so I believe by starting with such simple and small programs, it will eventually build up my skills and knowledge to attempt bigger ones. :)


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Weiye Chen
Singapore Singapore
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionRFID Chip Read can not more 10 digit in the TextBox! Pin
tsmeier30-Jul-12 23:37
membertsmeier30-Jul-12 23:37 
GeneralGood Work !!! Pin
dnpro28-Jan-09 22:15
memberdnpro28-Jan-09 22:15 
Generali'll write an article too!! Pin
Seishin#8-Apr-08 0:46
memberSeishin#8-Apr-08 0:46 
GeneralCool!! Pin
<font color=#008800>Muammar©8-Apr-07 23:22
memberMuammar©8-Apr-07 23:22 
GeneralThanks Pin
Laurent Cozic10-Oct-06 9:11
memberLaurent Cozic10-Oct-06 9:11 
GeneralFile to Hex Pin
chirag parikh4-May-06 21:21
memberchirag parikh4-May-06 21:21 
GeneralGood Work Pin
Saqib Mehmood8-Aug-05 3:28
memberSaqib Mehmood8-Aug-05 3:28 
GeneralHex To Text Pin
hmm211-Feb-05 15:33
memberhmm211-Feb-05 15:33 
GeneralRe: Hex To Text Pin
Weiye Chen11-Feb-05 17:13
memberWeiye Chen11-Feb-05 17:13 
GeneralCould do this with Windows Calculator. Pin
red_tomato14-May-04 9:12
memberred_tomato14-May-04 9:12 
GeneralRe: Could do this with Windows Calculator. Pin
Weiye Chen14-May-04 17:41
memberWeiye Chen14-May-04 17:41 
GeneralSuggestion Pin
leppie19-Jun-03 9:11
memberleppie19-Jun-03 9:11 
GeneralRe: Suggestion Pin
Weiye Chen19-Jun-03 17:44
memberWeiye Chen19-Jun-03 17:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 19 Jun 2003
Article Copyright 2003 by Weiye Chen
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid