Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello! I have a trouble. I have a textbox with data as string like "E4". How to convert this textbox.text data to a equal hex number E4? "E4" to &HE4
Posted
Updated 6-Apr-13 7:03am
v2
Comments
Zoltán Zörgő 6-Apr-13 13:10pm    
What about appending "&H" at the beginning?
Roman Gaisin 6-Apr-13 13:16pm    
No matter, I only have a string 4E and have to convert it into a HEX number 4E

You would absolutely be amazed to find this:
http://msdn.microsoft.com/en-us/library/bb311038.aspx[^]

Pleas read the documentation before posting a question. :)
 
Share this answer
 
Hexadecimal, octal, decimal, binary: they are only representations of the same number. There is no hex number 4E, there is only the value 78. You can parse the hexadecimal representation to get this value, and thank back again to your desired format - but do you really need this?
Check following code lines one by one:
C#
var input = "4E";
var x = Convert.ToInt32(input, 16);
Console.WriteLine(String.Format("&H{0:X}",x));
Console.WriteLine(String.Format("&H{0}",input));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900