Textbox和Combox限制只能输入数字的问题?
针对Textbox和Combox我分别写了一样的KeyPress函数,为什么Textbox执行得很好,而Combox的没有效果呢?
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim MidStr As String
MidStr = "0123456789"
If MidStr.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub
Private Sub ComboxBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim MidStr As String
MidStr = "0123456789"
If MidStr.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub