Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e _
As System.Windows.Forms.KeyPressEventArgs) Handles _
TextBox1.KeyPress
Dim myChar As Char '定义字符变量
myChar = e.KeyChar '通过KeyChar属性取得输入字符
'只接受数字和控制字符
If Char.IsDigit(myChar) OrElse Char.IsControl(myChar) Then
Else
e.Handled = True '屏蔽掉其他输入(系统不再进行显示处理)
End If
End Sub
As System.Windows.Forms.KeyPressEventArgs) Handles _
TextBox1.KeyPress
Dim myChar As Char '定义字符变量
myChar = e.KeyChar '通过KeyChar属性取得输入字符
'只接受数字和控制字符
If Char.IsDigit(myChar) OrElse Char.IsControl(myChar) Then
Else
e.Handled = True '屏蔽掉其他输入(系统不再进行显示处理)
End If
End Sub