第一个代码:
界面如图所示:
代码:
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As String
Dim max As Double
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
MsgBox "请输入完整!"
Exit Sub
End If
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
max = a
If max < b Then max = b
If max < c Then max = c
d = max
If d = a Then
If b + c > a Then
Text4.Text = "可以构成三角形"
Else
Text4.Text = "不可以构成三角形"
End If
ElseIf d = b Then
If a + c > b Then
Text4.Text = "可以构成三角形"
Else
Text4.Text = "不可以构成三角形"
End If
ElseIf d = c Then
If a + b > c Then
Text4.Text = "可以构成三角形"
Else
Text4.Text = "不可以构成三角形"
End If
End If
If Text4.Text = "可以构成三角形" Then
If a = b And b = c Then
Text4.Text = "可以构成等边三角形"
ElseIf a = b Or a = c Or b = c Then
Text4.Text = "可以构成等腰三角形"
End If
Else
Text4.Text = "不可以构成三角形"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Beep
R = MsgBox("你是否要退出程序??", vbQuestion + vbYesNo, "温馨提示")
If R = 6 Then
Unload Me
Else
Cancel = True
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
KeyAscii = 8
Exit Sub
End If
If KeyAscii < 47 Or KeyAscii > 58 Then
KeyAscii = 0
Beep '声音
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
KeyAscii = 8
Exit Sub
End If
If KeyAscii < 47 Or KeyAscii > 58 Then
KeyAscii = 0
Beep '声音
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
KeyAscii = 8
Exit Sub
End If
If KeyAscii < 47 Or KeyAscii > 58 Then
KeyAscii = 0
Beep '声音
End If
End Sub
你看看有什么错误的地方没?call me! QQ 137727650