Simple validating c input
Input focus will remain on the current control until the user changes the data to a valid input.
If you assigned Enable Allow Focus Change, the Validated event will not occur when you cancel the event, but focus will still change to the next control.
In the event, set the Cancel property to Note If you force the form to close in this manner, any data in the form's controls that has not already been saved is lost.
In addition, modal forms do not validate the contents of controls when they are closed.
You can validate the data in response to a user action, such as clicking a Save button or a Next link.
If you cancel the Validating event, the behavior of the control will be determined by what value that you assigned to Auto Validate.
If you assigned Enable Prevent Focus Change, canceling the event will cause the Validated event not to occur.
When users enter data into your application, you may want to verify that the data is valid before your application uses it.
You may require that certain text fields not be zero-length, that a field be formatted as a telephone number or other type of well-formed data, or that a string not contain any unsafe characters that could be used to compromise the security of a database.
For a code example that validates an email address in a Text Box, see Validating.