问题补充:
写出具体的程序编码,复制就能运行的那种
三个文本框,二个label,一个按钮的单击事件.
Private Sub Command1_Click()
Dim a, b, c As Single
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a = b And b = c Then
Label1.Caption = "等边三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Or a ^ 2 + c ^ 2 = b ^ 2 Or c ^ 2 + b ^ 2 = a ^ 2 Then
Label1.Caption = "直角三角形"
ElseIf a = b Or a = c Or b = c Then
Label1.Caption = "等腰三角形"
Else
Label1.Caption = "任意三角形"
End If
1:
If a > b Then
o = b
b = a
a = o
GoTo 1
ElseIf b > c Then
o = c
c = b
b = o
GoTo 1
End If
Label2.Caption = ((Sqr(b ^ 2 - ((b ^ 2 - a ^ 2 + c ^ 2) / (2 * c)) ^ 2)) * c) / 2
End Sub
不够完善,文本框内不能输入文字,不能输入不成三角形的三条边长度.
希望有高手可以改一下.
[此贴子已经被作者于2007-4-6 13:32:38编辑过]
三个文本框,二个label,一个按钮的单击事件.
Private Sub Command1_Click()
Dim a, b, c As Single
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a = b And b = c Then
Label1.Caption = "等边三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Or a ^ 2 + c ^ 2 = b ^ 2 Or c ^ 2 + b ^ 2 = a ^ 2 Then
Label1.Caption = "直角三角形"
ElseIf a = b Or a = c Or b = c Then
Label1.Caption = "等腰三角形"
Else
Label1.Caption = "任意三角形"
End If
1:
If a > b Then
o = b
b = a
a = o
GoTo 1
ElseIf b > c Then
o = c
c = b
b = o
GoTo 1
End If
Label2.Caption = ((Sqr(b ^ 2 - ((b ^ 2 - a ^ 2 + c ^ 2) / (2 * c)) ^ 2)) * c) / 2
End Sub
不够完善,文本框内不能输入文字,不能输入不成三角形的三条边长度.
希望有高手可以改一下.
Private Sub Command1_Click()
Dim a, b, c As Single
a = Text1.Text
b = Text2.Text
c = Text3.Text
If a = b And b = c Then
Label1.Caption = "等边三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Or a ^ 2 + c ^ 2 = b ^ 2 Or c ^ 2 + b ^ 2 = a ^ 2 Then
Label1.Caption = "直角三角形"
ElseIf a = b Or a = c Or b = c Then
Label1.Caption = "等腰三角形"
Else
Label1.Caption = "任意三角形"
End If
1:
If a > b Then
o = b
b = a
a = o
GoTo 1
ElseIf b > c Then
o = c
c = b
b = o
GoTo 1
End If
Label2.Caption = " 面积为 " & ((Sqr(b ^ 2 - ((b ^ 2 - a ^ 2 + c ^ 2) / (2 * c)) ^ 2)) * c) / 2
If ((Sqr(b ^ 2 - ((b ^ 2 - a ^ 2 + c ^ 2) / (2 * c)) ^ 2)) * c) / 2 = 0 Then Label1.Caption = "直线"
End Sub
加多这一是否好一点呢
我现在已经编出了完美的了```
三个文本框分别为text1,text2,text3,二个分别为label1,label2,
二个按钮分别为command1,command2
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label1.Caption = ""
Label2.Caption = ""
End Sub
Private Sub Command1_Click()
Label1.Caption = ""
Label2.Caption = ""
e = Text1.Text
f = Text2.Text
i = Text3.Text
If Not IsNumeric(e) Or Not IsNumeric(f) Or Not IsNumeric(i) Then
MsgBox "请输入正数", , "输入错误"
Exit Sub
End If
a = CCur(e)
b = CCur(f)
c = CCur(i)
If a + b <= c Or a + c <= b Or b + c <= a Then
Label1.Caption = "不能构成三角形"
GoTo 2
ElseIf a = b And b = c Then
Label1.Caption = "等边三角形"
ElseIf a ^ 2 + b ^ 2 = c ^ 2 Or a ^ 2 + c ^ 2 = b ^ 2 Or c ^ 2 + b ^ 2 = a ^ 2 Then
Label1.Caption = "直角三角形"
ElseIf a = b Or a = c Or b = c Then
Label1.Caption = "等腰三角形"
ElseIf a + b > c Or a + c > b Or b + c > a Then
Label1.Caption = "任意三角形"
End If
Label2.Caption = ((Sqr(b ^ 2 - ((b ^ 2 - a ^ 2 + c ^ 2) / (2 * c)) ^ 2)) * c) / 2
2:
End Sub
Private Sub Command2_Click()
End
End Sub