![]() |
Click here to advertise with us
|
|
|||||||
| VB.NET General Discussion VB.NET general discussion area |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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
|
|
|||
|
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:
Code:
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. |
|
||||
|
Code:
Dim Number As Integer
HexTextBox.Text = If(Integer.TryParse(NumberTextBox.Text.Trim, Number) = True, Number.ToString("x"), "Cannot be converted to Hex")
__________________
Currently using: VS 2005 & 2008 Pro w/sp1 on Win7 Ultimate x64. ![]() There are 3 kinds of people in the world: Those who can count and those who can't. 4 out of 3 people have trouble with fractions. Windows has a 64 bit GUI for a set of 32 bit extensions on a 16 bit shell for an 8 bit OS using a 4 bit kernel made by a 2 bit company that can't stand 1 bit of competition. |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|