一个小程序改了很多遍,求大神看看。。新手刚进来的
Private Sub Command1_Click()Text1.Text = " "
Cls
End Sub
Private Sub Form_Load()
Dim n As Integer
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) <> "=" Then
If Chr(KeyAscii) = "(" Then n = n + 1
If Chr(KeyAscii) = ")" Then n = n - 1
Else
' If n = 0 Then Print "左括号等于右括号"
'If n > 0 Then Print "左括号多于右括号" & n & "个,按“重置”按钮,重新输入"
'If n < 0 Then Print "右括号多于左括号" & -n & "个,按“重置”按钮,重新输入"
'Print "左括号等于右括号"
'End If
'If Chr(KeyAscii) = "=" Then
Select Case n
Case 0
Print "左括号等于右括号"
Case Is > 0
Print "左括号多于右括号" & n & "个,按“重置”按钮,重新输入"
Case Is < 0
Print "右括号多于左括号" & -n & "个,按“重置”按钮,重新输入"
End Select
Else
End If
End Sub
中间一些语句试了很多遍给注销了。。这个程序就是判断在文本框中输入的内容,其中的,左括号和右括号配对的问题