Celsius and Fahrenheit Conversion in VB.Net

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. convet212

Step 2

Do the form just like shown below. convet321

Step 3

Double click the “Celsius to Fahrenheit” button and do the following code for converting the Celsius to Fahrenheit.
  1. Dim c As Double
  2. Dim f As Double
  3.  
  4. c = Val(TextBox1.Text)
  5. If Val(c) = 0 And TextBox1.Text = “” Then
  6. MsgBox(“Enter Any number”, vbInformation, “Result”)
  7. TextBox1.Focus()
  8. Else
  9. f = (c * 9 / 5) + 32
  10. 'f = 9 * c \ 5 + 32
  11. MsgBox(“Fahrenheit :” & ” ” & f, vbInformation, “Result”)
  12. End If

Step 4

Write this code for converting the Fahrenheit to Celsius.
  1. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  2. Dim c As Double
  3. Dim f As Double
  4.  
  5. f = Val(TextBox1.Text)
  6. If Val(c) = 0 And TextBox1.Text = “” Then
  7. MsgBox(“Enter Any number”, vbInformation, “Result”)
  8. TextBox1.Focus()
  9. Else
  10. c = (f - 32) * 5 / 9
  11. MsgBox(“Celsius :” & ” ” & c, vbInformation, “Result”)
  12. End If
  13. 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.

Comments

Submitted byAnonymous (not verified)on Thu, 02/03/2022 - 21:05

Create a Vb.net program that will Convert the Celsius to Fahrenheit and Fahrenheit to Celsius. Variable: Celsius = 38, Fahrenheit = 108. Sub Main() Dim Celsius As________________ Dim Fahrenheit As________________ ________________ _________________________________ Console.WriteLine("Celsius: {0}", Celsius) ________________ _________________________________ Console.WriteLine("Fahrenheit: {0}", Fahrenheit) End Sub End Module

Add new comment