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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation

Status
Not open for further replies.

technohead

Technical User
Jan 12, 2002
64
0
0
US
hi i want ot validate a textbox so that only numbers and a dot can be entered.


thanks.
 
Use this same information that I gave you before just replace the decimal representations:

Public Function CustomKeys(KeyAscii As Integer) As Integer
Select Case KeyAscii
Case 46, 48 To 57
Case Else
KeyAscii = 0
End Select
CustomKeys = KeyAscii
End Function

Then call it in the text keypress event:

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = CustomKeys(KeyAscii)
End Sub

This will take care of #'s 0 - 9 and '.'

If you are wondering what other characters are go to
 
You may also want to add an '8' to the list of numbers so the user can backspace if they make a mistake. Sorry I did not include this the first time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top