Is functions
An editor has nominated this article for deletion. You are welcome to participate in the deletion discussion, which will decide whether or not to retain it. |
For validation of numbers in VB6 we can use function like IsNumeric() which text field as argument for which validation will be perform.
Example: Private Sub txtcodeno_Change() If Not IsNumeric(txtcodeno.Text) And txtcodeno.Text <> "" Then txtcodeno.Text = "" lblerror1.Visible = True Else lblerror1.Visible = False end if endsub
Where:
txtcodeno = Name of textbox on which validation will be perform lbderror = Name of label will visble true (default false)if characters or other symbols except numbers will be enter in txtcodeno filed
DESCRIPTION OF ABOVE CODE:
Take one [1] on form and give its name to txtcodeno. Take one label and set its name to lblerror1 and make its visible properties to false ans set caption to "Enter only numbers". Write above code in change event of txtcodeno textbox. Make visble propertis of lblerror1 to false in lostfocus even of txtcodeno textbox. OUTPUT:
When you will enter except numbers then you will get visible lable with message "Enter only numbers" and txtcodeno will clear.
THANK YOU.
This article has not been added to any content categories. Please help out by adding categories to it so that it can be listed with similar articles. (December 2010) |