If you are looking for a tutorial for the
conversion of Celsius and Fahrenheit in VB.Net, we’ll this tutorial is the one that is just right for you. This tutorial has a functionality that converts the number that you input to Fahrenheit and Celsius. It composed of label, textbox and two buttons inside the form. See the procedure below.
Creating Application
Step 1
Open
Microsoft Visual Studio 2015 and create a new windows form application.
Step 2
Do the form just like shown below.
Step 3
Double click the “
Celsius to Fahrenheit” button and do the following code for converting the Celsius to Fahrenheit.
Dim c As Double
Dim f As Double
c = Val(TextBox1.Text)
If Val(c) = 0 And TextBox1.Text = “” Then
MsgBox(“Enter Any number”, vbInformation, “Result”)
TextBox1.Focus()
Else
f = (c * 9 / 5) + 32
'f = 9 * c \ 5 + 32
MsgBox(“Fahrenheit :” & ” ” & f, vbInformation, “Result”)
End If
Step 4
Write this code for converting the
Fahrenheit to Celsius.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim c As Double
Dim f As Double
f = Val(TextBox1.Text)
If Val(c) = 0 And TextBox1.Text = “” Then
MsgBox(“Enter Any number”, vbInformation, “Result”)
TextBox1.Focus()
Else
c = (f - 32) * 5 / 9
MsgBox(“Celsius :” & ” ” & c, vbInformation, “Result”)
End If
End Sub
For any questions about this article. You can contact me @
Email –
[email protected]
Mobile No. – 09305235027 – TNT
FB Account – https://www.facebook.com/onnaj.soicalap
Or feel free to comment below.