在vb中判断一个三角形属于什么类型啊

来源:百度知道 编辑:UC知道 时间:2024/05/17 07:59:30
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single
If a = b And b = c Then
Label2.Caption = "此三角形是正三角形"
ElseIf a = b <> c And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf a = c <> b And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf b = c <> a And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf a = b <> c Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf a = c <> b Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf c = b <> a Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是直角三角形"
Else
Label2.Caption = "此三角形是一般三角形"
End If

End Sub
我这段代码哪错了啊,为什么老显示一个结果就是正三角形啊,哪位很懂的人给点提示吧。请尽快啊。不胜感激啊

修改下:
If a = b And b = c Then
Label2.Caption = "此三角形是正三角形"
ElseIf a = b And b <> c And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf a = c And c <> b And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf b = c And c <> a And a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是等腰直角三角形"
ElseIf a = b And b <> c Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf a = c And c <> b Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf c = b And b <> a Then
Label2.Caption = "此三角形是等腰三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Then
Label2.Caption = "此三角形是直角三角形"
Else
Label2.Caption = "此三角形是一般三角形"
End If

首先,你的a,b,c的值都没有输入,怎么判断呢!再有就是你的判断条件上有一点乱。我把你的代码稍改了点。你看一下:

Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single
a = Val(InputBo