With winter around and daily temperature change has become a concern for many people especially those who travel a lot. They are constantly checking out temperature readings everyday However, different parts of the world often use different temperature scales, some of them use Fahrenheit and some use Celsius, so the readings can be confusing. Therefore, it is nice if we have a program that can convert Celsius to Fahrenheit and vice versa. And I have done just that using Visual Basic 6. The code is like this:
Private Sub Command1_Click()
Dim cel, Fah As Single
cel = Val(txtC.Text)
Fah = Val(txtF.Text)
If txtC.Text <> “” And txtF = “” Then
Fah = ((9 / 5) * cel + 32)
txtF.Text = Round(Fah, 1)
Else
cel = (5 / 9) * (Fah - 32)
txtC.Text = Round(cel, 1)
End If
End Sub
Private Sub Command2_Click()
txtC.Text = “”
txtF.Text = “”
End Sub
click here for source
0 komentar:
Posting Komentar