Convert Number to Hexadecimal in VB.NET

In this article, we will create a program that can convert a given number into hexadecimal equivalent. Hexadecimal describes a base-16 number system, that is 0 to 9 and A to F. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one Button named Button1 and labeled it as "Convert". Insert two textboxes named TextBox1 for inputting a desired number and TextBox2 for displaying the output in the hexadecimal equivalent. You must design your interface like this: design 3. Put this code in your Button1_Click. This will trigger to convert the inputted number in textbox1 and display the output in hexadecimal form in textbox2.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim hexNumber As String = Hex(TextBox1.Text)
  3. TextBox2.Text = hexNumber
  4. End Sub
  5.  
We have first initialized variable hexNumber as a string that will hold the equivalent of a number inputted in textbox1 as we have the Hex function. Hex function returns a string that will represent the hexadecimal value of a number inputted in textbox1. Then the hexadecimal value equivalent in textbox1 will be displayed in textbox2.

Output:

output Download the source code below and try it! :) For more inquiries just contact my number or e-mail below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment