Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

How can make an application which convert Fahrenheit temperatures into Celsius and Celsius to Fahrenheit Using VB.Net

Author: DevASP
Download Source Code : 515_temprature_Converter.zip

In this simple article you will learn that how you can make an application which convert Fahrenheit temperatures into Celsius and Celsius to Fahrenheit.

Create New Project of windows application in VB.Net and drag four labels, two radio buttons, two numeric up down and two buttons on the form. Now write code against following event:

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        Label5.Text = Label5.Text.ToUpper

        Me.Text = "DevAsp"

        RadioButton1.Checked = True

        RadioButton2.Checked = False

        Label1.Text = Label1.Text.ToUpper()

        Label2.Text = Label2.Text.ToUpper()

        Label3.Text = Label3.Text.ToUpper()

        Label4.Text = Label4.Text.ToUpper()

        RadioButton1.Text = RadioButton1.Text.ToUpper()

        RadioButton2.Text = RadioButton2.Text.ToUpper()

        NumericUpDown1.Minimum = 0

        NumericUpDown1.Maximum = 500

        NumericUpDown2.Minimum = 0

        NumericUpDown2.Maximum = 500

 

        Label3.Enabled = False

        Label4.Enabled = False

        Button2.Enabled = False

        NumericUpDown2.Enabled = False

 

End Sub

 

 

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Label2.Text = NumericUpDown1.Value - 32

        Label2.Text = Label2.Text * 5

        Label2.Text = Label2.Text / 9

 

End Sub

 

 

 

Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

 

        If RadioButton1.Checked = True Then

 

            Label1.Enabled = True

            Label2.Enabled = True

            Button1.Enabled = True

            NumericUpDown1.Enabled = True

 

            Label3.Enabled = False

            Label4.Enabled = False

            Button2.Enabled = False

            NumericUpDown2.Enabled = False

 

            RadioButton2.Checked = False

        End If

 

End Sub

 

 

 

Private Sub RadioButton2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

 

        If RadioButton2.Checked = True Then

            Label1.Enabled = False

            Label2.Enabled = False

            Button1.Enabled = False

            NumericUpDown1.Enabled = False

 

            Label3.Enabled = True

            Label4.Enabled = True

            Button2.Enabled = True

            NumericUpDown2.Enabled = True

 

            RadioButton1.Checked = False

 

        End If

 

End Sub

 

 

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        Label3.Text = NumericUpDown2.Value * 9

        Label3.Text = Label3.Text / 5

        Label3.Text = Label3.Text + 32

 

End Sub

Article Comments
Hi
hey i have used two text box and one button tu calcute. i want to build code like user can enter in any of text box, and click calculate, so if user enterd tem in F then it will calculate in C and viceversa. can you help me to write code like that..

Posted on 4/26/2007 9:39:21 AM by Neha

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How to fill different Graphics shapes using System.Drawing.Graphics

Disclaimer - Privacy
© 2002-2017 DevASP.net