简体   繁体   中英

Textbox should allow only Integer. not decimal in vb.net

I want to allow only whole values and not decimal to the textbox in vb.net. Can anyone help me how to check validation on that.

Only allow numeric input:

    Private Sub TextBoxKeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox.KeyPress
            e.Handled = True
            If IsNumeric(e.KeyChar) Then e.Handled = False
        End Sub

For a more elaborate example : http://msdn.microsoft.com/en-us/library/ms229644(v=vs.80).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM