想限制某个文本框只能输入两位的字母,不能输入中文和数字,该怎么弄?

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= 65 And KeyAscii <= 90 Then
        Else
            KeyAscii = 0
        End If
    End Sub
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 8 Then Exit Sub
        If Len(Text1.Text) >= 2 Then
            KeyAscii = 0
            Exit Sub
        End If
        If KeyAscii >= 97 And KeyAscii <= 122 Or KeyAscii >= 65 And KeyAscii <= 90 Then
        Else
            KeyAscii = 0
        End If
    End Sub