vb编写程序 三角形
'这个你参考下,是刚给别人写的,你只要在后面加入求周长面积的代码就可以了
Dim a, b, c As Double
Dim P As String
Private Sub Command1_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) And IsNumeric(Text3.Text) Then
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If a + b > c And Abs(a - b) < c Then
P = "一般三角形!"
If a = b Or a = c Or b = c Then
P = "等腰三角形!"
If a = b = c Then
P = "等边三角形!"
End If
ElseIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b + c * c = a * a Then
P = "直角三角形!"
End If
Else
P = "不够成三角形!"
End If
MsgBox "经判断此三角形为: " & P, vbOKOnly, "三角形判断"
Else
MsgBox "请正确输入数字!", vbOKOnly, "三角形判断"
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Me.Caption = "三角形判断"
Label1.Caption = "第一条边长度:"
Label2.Caption = "第二条边长度:"
Label3.Caption = "第三条边长度:"
Command1.Caption = "判 断"
Command2.Caption = "退 出"
End Sub
2023-06-12 广告