Hola!!!
Yo lo hice de esta forma, ademas solo acepta numeros en el textbox:
Código vb:
Ver originalPublic Cont As Double
Private Sub Command1_Click()
MsgBox "Faltan " & Cont & " parentesis"
End Sub
Private Sub Text1_Change()
If Text1.Text = Empty Then Cont = 0
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not KeyAscii = 40 Then 'KEYASCII=40 ES (
If Not KeyAscii = 41 Then 'KEYASCII=41 ES )
If Not KeyAscii = 8 Then 'KEYASCII=8 ES BACKSPACE
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
End If
End If
End If
End If
If KeyAscii = 40 Then Cont = Cont + 1
If Cont = 0 Then
If KeyAscii = 41 Then
KeyAscii = 0
MsgBox "Falta un '('"
Exit Sub
End If
Else
If Not KeyAscii = 40 Then 'KEYASCII=40 ES (
If Not KeyAscii = 41 Then 'KEYASCII=41 ES )
If Not KeyAscii = 8 Then 'KEYASCII=8 ES BACKSPACE
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
KeyAscii = 0
End If
End If
Else
Cont = Cont - 1
If Cont < 0 Then MsgBox "Faltan " & Abs(Cont) & " parentesis"
End If
End If
End If
End Sub