我有以下代码限制2位数文本框的输入。我想知道如果现场已经存在'0',我是否有办法防止输入'00':
Private Sub txtLLFiftyFifty_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLLSwapQuestion.KeyPress, txtLLPlusOne.KeyPress, txtLLPhoneFriend.KeyPress, txtLLJumpQuestion.KeyPress, txtLLFiftyFifty.KeyPress, txtLLCrystalBall.KeyPress, txtLLAskExpert.KeyPress, txtLLAskAudience.KeyPress
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
End Sub
我尝试过以下条件,但它似乎没有做任何事情:
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 48) And Me.Text = "0" Then
e.Handled = False
End If