Home / Sex cam chat phone call / Validating event visual basic

Validating event visual basic

The new Visual Basic 6 validation mechanism is simple and can be implemented with little effort.But it isn't the magic answer to all your validation needs.

If Unload Mode = vb Form Control Menu Then On Error Resume Next Validate Controls If Err = 380 Then ' The current field failed validation.

This allows all controls to be validated and checked with almost no code.

I have a form with a textbox and numerous panels, buttons and other controls. However, certain buttons on the form (such as a cancel button) I don't want causing the validation code to run, so I set their Causes Validation property to False. I still get the validating code executed in situations I don't want it.

If this property is True, Visual Basic fires the Validate event in the control that's about to lose the focus, thus giving the programmer a chance to validate its contents and, if necessary, cancel the focus shift. Imagine that you have five controls on a form: a required field (a Text Box control, txt Required, that can't contain an empty string), a numeric field, txt Numeric, that expects a value in the range 1 through 1000, and three push buttons: OK, Cancel, and Help.

(See the figure below.) You don't want to perform validation if the user presses the Cancel or Help buttons, so you set their Causes Validation properties to False.

848 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*