20. Write a VB program to convert a temperature from Celsius to Fahrenheit and vice versa.


Dim c As Double
Dim f As Double
Private Sub CmdClr_Click()
TxtInput.Text = “”
TxtInput.SetFocus
End Sub

Private Sub Command1_Click()
c = Val(TxtInput.Text)
If Val(c) = 0 And TxtInput = “” Then
MsgBox “Enter Any number”, vbInformation, “Result”
TxtInput.SetFocus
Else
f = 9 * c \ 5 + 32
MsgBox “Fahrenheit :” & ” ” & f, vbInformation, “Result”

End If

End Sub

Private Sub Command2_Click()
f = Val(TxtInput.Text)
If Val(c) = 0 And TxtInput = “” Then
MsgBox “Enter Any number”, vbInformation, “Result”
TxtInput.SetFocus
Else
c = (f – 32) * 5 \ 9
MsgBox “Celsius :” & ” ” & c, vbInformation, “Result”

End If
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s