Number to Hex and vice versa

With VB6 and older version, it was quite hard to do this conversion. But now I'll show you a small function that will solve the whole problem.
The new Hex Function
First make a new form with a Text Box and a button
Then place the following code in the button (onclick())
MsgBox(Hex(TextBox1.Text))
Now run the application and tape some numbers in the textbox and press the button.
A message box will give you the Hex value !
Vice Versa ;)
Here's a very nice class of functions for conversion (Convert.)
We'll use the Convert.ToInt32. But this is a little more complexed. We'll add a new thing, here you'll need to define the Base
For Hexadecimal, the base is : 16
So place the following code
MsgBox(Convert.ToInt32(TextBox1.Text, 16))
Hope it helps some of you !
Question ? Post a comment

0 comments:

Post a Comment