27/11/2011

How to convert temperature from Fahrenheit scale to Celsius scale? Vb.net code for Beginner

It is   very easy to code a windows form for converting temperature from Fahrenheit to Celsius. Just add a new windows form and add two label controls, tow text box controls  and one button control on windows form and set their property accordingly



S.No       Control                                        Property

01            Label1                       Text Property- Temprature in Fahrenheit
02            Label2                       Text Property- Temperature in Celsius
03           Textbox1                   Name Property-txtFehrenhiet
04            Tetxbox2                  Name Property-TxtCelsius
05           Button1                     Text property-Convert Temprature
                                                  Name Property- BtnTemp

The windows form will be as below:

and write following visual Basic Code on click event of Convert Temperature button.


Private Sub BtnTemp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnTemp.Click
        TxtCelsius.Text = CStr((Val(txtFehrenhiet.Text) - 32) * 5 / 9)
  
    End Sub.

No comments:

Post a Comment

What & How