Only accept digits for textbox

前端 未结 8 959
小鲜肉
小鲜肉 2020-12-10 16:13

I found this code for making my textbox only accept numbers.

Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.Key         


        
8条回答
  •  無奈伤痛
    2020-12-10 16:52

    Private Sub TMarksTextBox_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TMarksTextBox.KeyPress
            If e.KeyChar < "0" OrElse e.KeyChar > "9" AndAlso e.KeyChar <> ControlChars.Back Then
                e.Handled = True
            End If
    End Sub
    

提交回复
热议问题