只题目2吗
新建工程,添加四个Label,Caption属性分别为“边长a”“边长b”“边长c”“面积S”,添加四个TextBox,一个CommandBottn,命令按钮的Caption属性为“求三角形的面积”
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single
Dim p As Single, s As Single
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
'先要判断能不能构成三角形
If a + b > c And a + c > b And b + c > a Then
s = Sqr((a + b + c) * (a + b - c) * (a + c - b) * (b + c - a)) / 4
Else
MsgBox "不能构成三角形", , "提示"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End If
Text4.Text = s
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
问老师家啊