扩展文本框中可接受输入的限制

时间:2015-08-06 16:45:37

标签: vb.net validation

我有以下代码限制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

0 个答案:

没有答案