Vb code for validating textbox Live xxx chat room paksitan
(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.
They work together as follows: When the input focus leaves a control, Visual Basic checks the Causes Validation property of the control that is about to receive the focus.
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.
Your code won't raise an error, even if the second field doesn't contain a valid number!
1000 Then Cancel = True End If If Cancel Then Msg Box "Please enter a number in range [1-1000]", vb Exclamation End If End Sub In some circumstances, you might want to programmatically validate the control that has the focus without waiting for the user to move the input focus.The second flaw is that the Validate event doesn't fire when you're moving the focus from a control whose Causes Validation property is False, even if the control that receives the focus has its Causes Validation property set to True.The new Visual Basic 6 validation mechanism is simple and can be implemented with little effort.The Validate event fires whenever the user attempts to set focus to another field on the same form or when the form unloads from memory while the current field has focus.A programmer can evaluate the state of the data at that point and react to any error in the data either by: Listing 5.4 illustrates the use of the Validate event procedure to perform validation and to decide whether or not to keep focus on the current control.
The Validate event and the accompanying Causes Validate property are new to VB6 and give programmers a much-needed replacement for older, more cumbersome techniques of field validation.