Results 1 to 16 of 16

Thread: validate event

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709
    Hi

    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

    How do I do It ?

    thanks

  2. #2
    New Member
    Join Date
    Mar 2001
    Location
    France
    Posts
    13
    Just a suggestion

    Why don't you create a boolean set it to false when the user click Cancel, then in the validate event code do nothing if the boolean is false!

    But perhaps, i don't really understand what u need!

  3. #3

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Unhappy validate event

    Hi , thanks

    I tried but do not work


    thanks

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    i just tried this...


    Code:
    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"

  5. #5

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709
    Hi

    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


    thanks

  6. #6
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Set the causes validation property of the cancel button to false.

  7. #7

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    validate event

    when I set to false ? , because if I set to false, It go out all.

  8. #8
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768

    Re: validate event

    Why don't you just set the causesvalidation property to false on the cancel button and it will not run the validate event for the text box.

  9. #9
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    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".

  10. #10
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768

    JAMES That is funny

    That's an actual question for the Desktop 70-175 test exam for the MCSD.

  11. #11
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Yep..I remember that question, I got it correct
    I saw it on the 176 exam.

  12. #12
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    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

  13. #13
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    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.

  14. #14
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Check this out for strange:

    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

  15. #15

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    validate event

    How I setting the causes validation property from Cancel Button ?

    the textbox is with focus, only in second click It look the variable tmp = true


    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


    Please help me
    Attached Files Attached Files

  16. #16
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    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.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width