VB.NET tutorials : How to convert Binary to Decimal, Binary to Hexadecimal and Decimal to Binary, Decimal to Hexadecimal using Vb.Net
VB.NET Converter - How to create simple application that convert from Binary to Decimal or Binary to Hexadecimal, convert from Decimal to Binary or Decimal to Hexadecimal and Convert from Hexadecimal to Decimal or to Binary using Vb.Net windows application.
Please Read :
Just compile and run your application and show me what happend.
Download VB.NET Convert Full Source Code
Please Read :
Create VB.NET Converter Project
Now we will try to create new project in your visual studio and rename it with "NetConverter", then at the Form1.vb please design look like this picture :Source Code VB.NET Simple Converter
Just write all source code below to convert a value from TextBox1.text and showing into TextBox2.TextLoad Event
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Add items into ComboBox1
ComboBox1.Items.Add("Binary")
ComboBox1.Items.Add("Decimal")
ComboBox1.Items.Add("Hexadecimal")
' Add items into ComboBox1
ComboBox2.Items.Add("Binary")
ComboBox2.Items.Add("Decimal")
ComboBox2.Items.Add("Hexadecimal")
' Add Text into ComboBox1
ComboBox1.Text = "Select Format"
' Add Text into ComboBox1
ComboBox2.Text = "Select Format"
End Sub
Button1 Click Event
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Strconvert As String = TextBox1.Text
Dim Decimals As Integer
Dim hexadecimal As String
Dim Binary As String
Dim x As Integer
' convert Binary to Binary
If ComboBox1.Text = "Binary" And ComboBox2.Text = "Binary" Then
TextBox2.Text = TextBox1.Text
' convert Binary to Decimal
ElseIf ComboBox1.Text = "Binary" And ComboBox2.Text = "Decimal"
Decimals = Convert.ToInt32(Strconvert, 2)
TextBox2.Text = Decimals.ToString
' convert Binary to Hexadecimal
ElseIf ComboBox1.Text = "Binary" And ComboBox2.Text = "Hexadecimal"
Decimals = Convert.ToInt32(Strconvert, 2)
hexadecimal = Convert.ToString(Decimals, 16)
TextBox2.Text = hexadecimal
' convert Decimal to Binary
ElseIf ComboBox1.Text = "Decimal" And ComboBox2.Text = "Binary"
x = Convert.ToInt32(Strconvert)
Binary = Convert.ToString(x, 2)
TextBox2.Text = Binary
' convert Decimal to Hexadecimal
ElseIf ComboBox1.Text = "Decimal" And ComboBox2.Text = "Hexadecimal"
x = Convert.ToInt32(Strconvert)
hexadecimal = Convert.ToString(x, 16)
TextBox2.Text = hexadecimal
' convert Hexadecimal to Binary
ElseIf ComboBox1.Text = "Hexadecimal" And ComboBox2.Text = "Binary"
Decimals = Convert.ToInt32(Strconvert, 16)
Binary = Convert.ToString(Decimals, 2)
TextBox2.Text = Binary
' convert Hexadecimal to Decimal
ElseIf ComboBox1.Text = "Hexadecimal" And ComboBox2.Text = "Decimal"
Decimals = Convert.ToInt32(Strconvert, 16)
TextBox2.Text = Decimals.ToString
Else
If ComboBox1.Text = "Select Format" Or ComboBox2.Text = "Select Format" Or ComboBox1.Text = "" Or ComboBox2.Text = "" Then
MsgBox("Please Insert Select type to convert")
End If
End If
End Sub
Just compile and run your application and show me what happend.
Download VB.NET Convert Full Source Code
COMMENTS