Question Decimal to hex conversion

skitz

Member
Joined
May 8, 2009
Messages
15
Programming Experience
Beginner
i have 2 textbox's 1 button and im trying to convert the text in one textbox(decimal) to show a hex value in the other textbox via the button click event im at a bit of a loss could someone help me out a bit thanks
 
Decimal to Hexadecimal

The Hex value is actually a string. You need to convert the decimal string from the textbox into a number and convert it back to a string with the option to display it as a Hex value. Here is the code:


VB.NET:
		Dim num As Integer
		Integer.TryParse(TextBox1.Text, num)
		TextBox2.Text = Convert.ToString(num, 16).ToUpper


Note: You can convert to binary or octal just as easily by replacing the 16 with a 2 or an 8.
 
Back
Top