关于vb问题,小弟急想知道答案的

来源:百度知道 编辑:UC知道 时间:2024/06/30 13:08:44
用inputbox输入三角形的三边a,b,c判断能否构成三角形。若能构成三角形,求出面积(保留三位小数);否则用msgbox显示“不能构成三角形”的信息。要求:对输入的数据用isnumeric函数进行测试,若为非数值显示“输入错误”
我自己也有做..不过没有达到效果,我需要的是一段完整的程序

呵呵.捡分喽..

Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double, p As Double, s As Double
inputaa:
tmp = InputBox("请输入第1个边的长度")
If IsNumeric(tmp) = False Then
MsgBox "输入错误"
GoTo inputaa
End If
a = tmp

inputbb:
tmp = InputBox("请输入第2个边的长度")
If IsNumeric(tmp) = False Then
MsgBox "输入错误"
GoTo inputbb
End If
b = tmp

inputcc:
tmp = InputBox("请输入第3个边的长度")
If IsNumeric(tmp) = False Then
MsgBox "输入错误"
GoTo inputcc
End If
c = tmp

If a + b < c Or a + c < b Or b + c < a Then
MsgBox "不能构成三角形"
Exit Sub
End If
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
Print "三角形的面积为" & Format(s, "0.000")
End Sub

Private Sub Form_Click()
Dim a(1 To 3) As Double, p As Double, s As Double
Cls