简单的vb帮忙做一下

来源:百度知道 编辑:UC知道 时间:2024/06/17 11:52:19
编写一个华氏温度与摄氏温度之间转换的程序.
提示:华氏温度=摄氏温度*9/5+32
摄氏温度=(华氏温度-32)*5/9
能不能用做简单的方式,大小长短什么都不要,我会给你加分的,太谢谢你了

添加控件label1、label2、text1、text2、command1、command2
以下是全部代码
Form_Load事件中的代码是定义各控件的名称、大小和位置,这些可以省略,不过你得在窗体里面自己调各个控件的名称大小位置,主要代码就是两个Command的Click事件

Private Sub Command1_Click()
Text2.Text = Val(Text1.Text) * 9 / 5 + 32
End Sub

Private Sub Command2_Click()
Text1.Text = (Val(Text2.Text) - 32) * 5 / 9
End Sub

'-------------以下可以省略------------

Private Sub Form_Load()
With Me
.Height = 1845
.Width = 4800
End With

With Label1
.Caption = "摄氏温度"
.Top = 360
.Left = 240
.AutoSize = True
End With

With Label2
.Caption = "华氏温度"
.Top = 840
.Left = 240
.AutoSize = True
End With

With Text1
.Text = ""
.Top = 240
.Left = 1320
End With

With Text2
.Text = ""
.Top = 720
.Left = 1320
End With

With