我尝试了以下代码:
Private Sub txtName_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtName.KeyPress
' allow upper and lower case A-Z, and backspace
If Not Chr(KeyAscii) Like "[A-Za-z]" And KeyAscii <> 8 Then KeyAscii = 0
End Sub
但它给出了:
未声明“KeyAscii”。由于其保护级别,它可能无法访问。
关于如何只允许字母表的任何想法?