Visual Basic .NET Forums  
Click here to advertise with us

Go Back   Visual Basic .NET Forums > VB.NET > VB.NET General Discussion

VB.NET General Discussion VB.NET general discussion area

VB.NET Forums Newsletter Signup:
Email address:


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2009, 3:37 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 15
Reputation: 12
skitz is on a distinguished programming path ahead
Default Decimal to hex conversion

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-09-2009, 4:08 PM
VB.NET Forum Genius
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2004
Posts: 206
Reputation: 104
Solitaire probably authored a book by nowSolitaire probably authored a book by now
Default 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:


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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-09-2009, 4:50 PM
JuggaloBrotha's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Jun 2004
Location: Lansing, MI; USA
Age: 25
Posts: 3,549
Reputation: 355
JuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NETJuggaloBrotha master of VB.NET
Default

Code:
Dim Number As Integer
HexTextBox.Text = If(Integer.TryParse(NumberTextBox.Text.Trim, Number) = True, Number.ToString("x"), "Cannot be converted to Hex")
Standard Numeric Format Strings
__________________
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-09-2009, 5:09 PM
VB.NET Forum Newbie
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: May 2009
Posts: 15
Reputation: 12
skitz is on a distinguished programming path ahead
Default

thank you very much
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





All times are GMT -4. The time now is 1:02 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2


For advertising opportunities click here.