How do I out form a textbox when the user click a button, I have a textbox and someone buttons and want that when the user click in the CANCEL button, It ignore the validate event
Dim tmp As Boolean
Private Sub Command1_Click()
tmp = True
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
If tmp = True Then Exit Sub
MsgBox "hello"
End Sub
VBBrowser v2.0.6
it worked fine
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
do not work , because the textbox is with setfocus, It work in the second time that I click in the button, I want that with the focus in the text box , It look that I clicked in the button
By setting the causes validation property to false, when cllick the cancel button it will not trigger the validate event in the control that has the focus. This is what you asked, is it not?
Please be more specific when you say "it go out all".
Forms & controls section. I haven't taken it yet. I am studying iam set to take it in two weeks. Any tips? I have tried to get the transcenders "no luck". I have the sybex version,but they donot compare to the transcenders. Everyone want's money for them and i can understand if they paid for them. I would give them out to help a fellow programmer. jeje
Well, basically my test revolved around COM, Deployment, and Debugging (mostly watches). The form and controls questions are a cake walk if you understand the main concepts and how they flow together. Good luck, I didn't use the transcenders, I just studied for about 4 days and went ahead and took it. Not that tough, dont sweat it to much.
To a new project add two text boxes. Dump in the code below, and try and enter non numeric data, you can't, which is cool.
Now change the causes validation property of textbox1 to false. Now try and enter data, you can enter non-numeric data in both text boxes, when text1 data should be validated when tabbing to text2.
So you should be very careful when setting causes validation to false. Only do this for a cancel button, otherwise always leave causes validation = true. That's my conclusion anyway, what do others think?
Code:
Private Sub Text1_Validate(Cancel As Boolean)
If Not IsNumeric(Text1) Then Cancel = True
If Cancel = True Then MsgBox "Please enter numeric data only"
End Sub
Private Sub Text2_Validate(Cancel As Boolean)
If Not IsNumeric(Text2) Then Cancel = True
If Cancel = True Then MsgBox "Please enter numeric data only"
End Sub
You don't have to set the causes validation property via code, you can do it design time, usually about five properties below where you change the control name alphabetically.
See attached for example where the causes validation property of the cancel button has been set to false.