戏剧知识竞赛课件免费:vb小程序 谁能帮帮嘛

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/14 10:23:29
编一个华氏温度与摄氏温度之间转换的程序!要用转换公式F=9/5C+32 C=5/9(F-32)
谁编个发给我 谢谢了
jimna@163.com

给你来个更方便的,在文本框内容修改后就即时计算,其中的Bz变量是防止两个文本框重复调用的。(我已经调试通过)

Option Explicit
Dim Bz As Long

Private Sub Text1_Change()
If Bz = 0 Then Bz = 1
If Bz = 1 Then
Text2 = 9 / 5 * Val(Text1) + 32
Bz = 0
End If
End Sub

Private Sub Text2_Change()
If Bz = 0 Then Bz = 2
If Bz = 2 Then
Text1 = (Val(Text2) - 32) * 5 / 9
Bz = 0
End If
End Sub

要使用转换的公式是:F=9/5*C+32

其中F为华氏温度,C为摄氏温度。

解答:

程序代码如下:

Private Sub Command1_Click()

If Text1.Text <> "" Then

Text2.Text = 9 / 5 * Text1.Text + 32

End If

End Sub

Private Sub Command2_Click()

If Text2.Text <> "" Then

Text1.Text = (Text2.Text - 32) * 5 / 9

End If

End Sub