Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, August 1, 2011

VB-77 : Temperature Conversion

Write a program in VB to convert the Celsius to Fahrenheit and Fahrenheit to Celsius.
Provide 2 buttons and 2 TextBoxes.One Button converts Fahrenheit to Celsius and the other convert Celsius to Fahrenheit. Use the formula :
Celsius=(5/9)*(Fahrenheit-32)
Refer Conversion of Temperature also.

(A)Program Design : 




(B) Property(Controls Used) :
  • One Label " Enter Temperature"
  • 2 TextBoxes (One for getting input from the user-Text1 , and the other is for displaying result-Text2)
  • 2 Command Buttons - Celsius & Fahrenheit
(C) Attaching Code to the Object :

Dim c, f As Double
Private Sub Command1_Click()
f = Val(Text1)
c = Round((5 / 9) * (f - 32), 2)
Text2 = f & " Degree Fahrenheit=" & c & " Degree Celsius"
End Sub
Private Sub Command2_Click()
c = Val(Text1)
f = Round((c * 1.8) + 32, 2)
Text2 = c & " Degree Celsius=" & f & " Degree Fahrenheit"
End Sub





(D) Output :




(E) Errors :

If found any errors while running your VB program, please click this link   Possible Errors while running VB Programs to get a solution.



      • ====================================================================
        Back to Home   &  VB
    ===========================================================

    No comments: