第1个回答 2013-02-18
直接写一起,点计算就出结果,为什么还要自定义函数呀?
直接在你计算的那个按钮下代码就行了
Private Sub CommandButton1_Click()
Dim a, b, c, p, s
a = Val(TextBox1.Value)
b = Val(TextBox2.Value)
c = Val(TextBox3.Value)
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
TextBox4.Value = s
End Sub
结果保留两位小数
Private Sub CommandButton1_Click()
Dim a, b, c, p, s
a = Val(TextBox1.Value)
b = Val(TextBox2.Value)
c = Val(TextBox3.Value)
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
TextBox4.Value = Round(s, 2)
End Sub