Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding difference between number and letter.

Status
Not open for further replies.

PrograMan

Programmer
Jul 21, 2001
59
US
I saw this before but I don't remember which post it's in. I'm trying to find out how to know whether the user put in any character that's not a number inside a text field.
 
This will allow numeric input such as -23 or 34.56 or ..
-185.74

Private Sub Text1_Change()
If Not ValidateNumeric(Text1.Text) Then
Text1.Text = ""
End If
End Sub

Private Function ValidateNumeric(strText As String) _
As Boolean
ValidateNumeric = CBool(strText = "" _
Or strText = "-" _
Or strText = "-." _
Or strText = "." _
Or IsNumeric(strText))
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top