VB 求三角形面积,求救

2024-11-26 17:44:07
推荐回答(2个)
回答1:

改成下面的试试
Dim a as double
dim b as double
dim c as double
dim p as double
dim s as double
Private Sub Command1_Click()
'If a = "" Then '这个可以不要
a = Text1.Text
b = Text2.Text
c = Text3.Text
'End If
If a + b < c Then
MsgBox "输入的三条边不能构成三角形!", , "提示"
Else
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
Picture1.Cls
Picture1.Print "面积=" & s
End If
End Sub

Private Sub Text3_KeyUp(KeyCode As Integer, Shift As Integer)
Command1.Enabled = True
'这一条写着干吗?如果要用那就是必须先把COMMAND1的ENABLED设为FALSE
End Sub

回答2:

a,b,c 赋值时用的是文本框.text,文本型的变量可以做加减的计算吗?