如何在 VB.NET/Visual Studio 2008 中允许空格键和退格键?
示例代码:
Private Sub txtname_KeyPress(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtname.KeyPress
If e.KeyChar < "A" Or e.KeyChar > "z" And e.KeyChar <> ControlChars.Back Then
e.Handled = True
txtname.Clear()
Else
End If
End Sub