Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double
Dim s As Double, area As Double, r As Integer
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
If a + b > c Or a + c > b Or b + c > a Then
s = (a + b + c) / 2
area = Sqr(s * (s - a) * (s - b) * (s - c))
MsgBox "三角形的面積是:" & Str(area), , "計算三角形面積程序"
Else
MsgBox "輸入的三邊不能構成三角形"
End If
End Sub
Private Sub Form_Load()
Text1 = "40"
Text2 = "50"
Text3 = "80"
Command1.Caption = "計算"
End Sub