Private Sub Command1_Click()
Dim x%, y%, z%, s As Single, b As Boolean, h As Single
'$ string 字符类型
'% integer 整型
'& long 长整型
'# double 双精度浮点型
'! single 单精度浮点型
x = InputBox("请输入三角形的边长")
y = InputBox("请输入三角形的边长")
z = InputBox("请输入三角形的边长")
b = pd(x, y, z)
h = (x + y + z) / 2
If b Then
s = Sqr(h * (h - x) * (h - y) * (h - z))
Print "三角形面积是"; s
Else
Print "不能构成三角形"
End If
End Sub
Public Function pd(x, y, z) As Boolean
If x > 0 And y > 0 And z > 0 And x + y > z And x + z > y And y + z > x Then
pd = True
Else
pd = False
End If
End Function
Dim x%, y%, z%, s As Single, b As Boolean, h As Single
'$ string 字符类型
'% integer 整型
'& long 长整型
'# double 双精度浮点型
'! single 单精度浮点型
x = InputBox("请输入三角形的边长")
y = InputBox("请输入三角形的边长")
z = InputBox("请输入三角形的边长")
b = pd(x, y, z)
h = (x + y + z) / 2
If b Then
s = Sqr(h * (h - x) * (h - y) * (h - z))
Print "三角形面积是"; s
Else
Print "不能构成三角形"
End If
End Sub
Public Function pd(x, y, z) As Boolean
If x > 0 And y > 0 And z > 0 And x + y > z And x + z > y And y + z > x Then
pd = True
Else
pd = False
End If
End Function