User control validating event Roochat sexs
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.If you determine that the control's data is not valid, you can cancel the Validating event by setting this object's Cancel property to .If you do not set the Cancel property, Windows Forms will assume that validation succeeded for that control, and raise the Validated event.
Which you set to False on, say, the Cancel button of a dialog. Validating If Type Of sender Is Text Box Then Dim tb As Text Box = sender 'Check if the Text Box is empty If String. Trim()) Then 'Show error message using Error Provider Me. Set Error(tb, "Error message") 'Cancel the events of the sender after Validating event e. Windows Forms provides several ways for you to validate input in your application.If you need to require users to enter data in a well-defined format, such as a telephone number or a part number, you can accomplish this quickly and with minimal code by using the Masked Text Box control.