Text box validating event

(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.

The default value for this property is True, so you don't have to modify it for the other controls.

VB6 controls fire the Validate event first and then the Lost Focus event; if the Validate sets Cancel=True, then the Lost Focus event is never fired.Back Color = vb Yellow End Sub Private Sub Text1_Lost Focus() Text1.Back Color = vb White End Sub Private Sub Text1_Validate(Cancel as Boolean) Cancel = (Text1. In some applications, however, the code in the Text1_Lost Focus method might depend on some variable that has been set in the Validate event.But in the real world, you need to handle unexpected problems when your code is running.The user might delete a critical file or enter invalid data.