Numeric Text box

 

Put the following code in Textbox Ker Press event.

This code will allow only Numbers in the Textbox

Dim isBackSpace As Boolean = False

        Dim isKey As Boolean = [Char].IsDigit(e.KeyChar)

        If Asc(e.KeyChar) = 8 Then

            isBackSpace = True

        End If

        If Not isKey AndAlso Not isBackSpace Then

            e.Handled = True

        End If

If you want to put decimal also in the text box the use the following code.

Dim txtbox As TextBox

            txtbox = sender

            Dim isBackSpace As Boolean = False

            Dim isKey As Boolean = [Char].IsDigit(e.KeyChar)

            If Asc(e.KeyChar) = 8 Then

                isBackSpace = True

            End If

            If Not isKey AndAlso Not isBackSpace AndAlso txtbox.Text.Contains(".") Then

                e.Handled = True

            End If