0

I am trying to per textchanged in a textbox call an isnumeric function. I cant seem to get it to work.

function:
[ Private Function IsNumericCheck(ByVal CheckVal As String) As String

'check for numeric values and return boolean

If IsNumeric(CheckVal) = False Then
Return False
Else
Return True
End If

End Function]

text changed
[Private Sub tHeight_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tHeight.TextChanged

'set variable
CheckVal = tHeight.Text
'call isnumeric function
IsNumericCheck(CheckVal)

If False Then
MessageBox.Show("Only Enter Nunmeric Values")
End If
End Sub]

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by nedrosat
0

instead of checking all the time the whole text you can use this code:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Not Char.IsNumber(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub

this will allow only numbers beeing written in the textbox and ignores everything else

0

instead of checking all the time the whole text you can use this code:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Not Char.IsNumber(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub

this will allow only numbers beeing written in the textbox and ignores everything else

Thank you that works great...

0

instead of checking all the time the whole text you can use this code:

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Not Char.IsNumber(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub

this will allow only numbers beeing written in the textbox and ignores everything else

The probleme here is when we want to remove a number using "Delete Key" they'll not delete because it's counting as a alphabet So We should have a Soulition here to this problem :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.