华氏温标与摄氏温标的转换步骤:1.打开程序。2.插入五个label和一个text和两个command。3.编写程序。
程序如下:
Option Explicit
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then Text1.Text = "0"
Label3.Caption = TransTh(Val(Text1.Text), True)
Label4.Caption = "摄氏度"
Label5.Caption = "华氏度"
End Sub
Private Sub Command2_Click()
If Trim(Text1.Text) = "" Then Text1.Text = "0"
Label3.Caption = TransTh(Val(Text1.Text), False)
Label4.Caption = "华氏度"
Label5.Caption = "摄氏度"
End Sub
Private Function TransTh(sngT As Single, blnCtof As Boolean) As String
If blnCtof Then
TransTh = Format(sngT * 9 / 5 + 32, "0.#")
Else
TransTh = Format((sngT - 32) * 5 / 9, "0.#")
End If
End Function
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
4.运行程序。5.检查错误。6.再次运行。7.重复操作,直到成功。8.保存文件。9.退出程序。10.做出总结。