Celsius and Fahrenheit Conversion in VB.Net

Submitted by: 
Visitors have accessed this post 1085 times.

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.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.