Results 1 to 20 of 20

Thread: Validate Event (Take two)

  1. #1

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Validate Event (Take two)

    Hi everybody !

    I have already asked the same thing here:http://www.vbforums.com/showthread.php?t=436068

    Now Im back, because I dont found the solution ???

    I attached with this thread, a very little project that shows my problem...Cloud you try it please ?

    I have a textbox (Text1) with a validate event. If this textbox is empty it's supposed to keep the focus and it's not the case because I can go to another TAB ? Why ? Is it normal or no ?

    Thanks for your help !
    Attached Files Attached Files
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Validate Event (Take two)

    This will fix it.

    VB Code:
    1. Private Sub Text1_LostFocus()
    2.  
    3.     If LenB(Trim(Text1.Text)) = 0 Then
    4.         SSTab1.Tab = 0
    5.         Text1.SetFocus
    6.     End If
    7.  
    8. End Sub

  3. #3

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate Event (Take two)

    Just to be sure, I can erase this Text1_Validate(Cancel As Boolean) ???
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Validate Event (Take two)

    Quote Originally Posted by DubweiserTM
    Just to be sure, I can erase this Text1_Validate(Cancel As Boolean) ???
    I'm guessing at the functionality you want but no. My change only checks when you change to a different tab and not if you go to a different control on the same tab.

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    Using Lost_Focus cannot be a solution, though. That will defeat the purpose of validation.
    it's quite interesting - running your project "as is" replicates the probles you described. However, replacing original tab control with new "fixes" the problem. And I couldn't find any discrepancies in the settings... Strange.

  6. #6

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate Event (Take two)

    Thanks !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  7. #7

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate Event (Take two)

    Quote Originally Posted by RhinoBull
    Using Lost_Focus cannot be a solution, though. That will defeat the purpose of validation.
    it's quite interesting - running your project "as is" replicates the probles you described. However, replacing original tab control with new "fixes" the problem. And I couldn't find any discrepancies in the settings... Strange.
    Im not really sur if I understand you ? I delete the TAB and I add a new one ? If its this I tried it and it's not okay..
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    Quote Originally Posted by DubweiserTM
    Im not really sur if I understand you ? I delete the TAB and I add a new one ? If its this I tried it and it's not okay..
    Well, it is for me... So, it must be the control on your system. Did you install all service packs?
    Or, perhaps you want to try using TabStrip control instead. It's not a container so you would have to use Picturebox or frame for each tab you create but it's better control over all and always prefer it to SSTab.

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Validate Event (Take two)

    I'm sorry Rhino but I don't understand why you say that the "Lost_Focus cannot be a solution". I would expect that the Validate event would fire when the tab is changed but if it doesn't then what's the matter with checking the textbox value on the tab number change and if it fails validation then stetting focus to the textbox?

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    If Validate isn't fired (and it must) then there is something wrong with tab control itself because it doesn't fire validation. If I ddn't see it myself I wouldn't believe it... I haven't seen it before... And Lost_Focus is no substitution for the Validate (and visa versa)... Each event is important and has its purpose.

  11. #11
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Validate Event (Take two)

    Quote Originally Posted by RhinoBull
    If Validate isn't fired (and it must) then there is something wrong with tab control itself because it doesn't fire validation. If I ddn't see it myself I wouldn't believe it... I haven't seen it before... And Lost_Focus is no substitution for the Validate (and visa versa)... Each event is important and has its purpose.
    All true but sometimes you need to be pragmatic.

  12. #12

  13. #13

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate Event (Take two)

    Do I have to call Bill Gates ???
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  14. #14
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Validate Event (Take two)

    Interesting! The Label controls seem to be causing the problem. Remove them and everything works as expected.

    The usual fix : use a Frame control on every Tab and put your controls in the Frame. Using Frames solves many quirks with the SSTab, including this one.

    [Edit]
    I just ran some more tests. It seems the problem occurs if there is at least one Label, Image, Line or Shape control anywhere on the SSTab (any Tab). I can't remember if I have VB SP6 installed on this pc. My versions are

    VB - 6.0.81.76
    MSVBVM60 - 6.0.96.90
    TabCtl32 - 6.0.90.43
    Last edited by brucevde; Nov 12th, 2006 at 02:19 AM.

  15. #15
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    Quote Originally Posted by brucevde
    Interesting! The Label controls seem to be causing the problem.
    It's quite Interesting! I couldn't let go so I did the same thing - deleted both labels - and I can confirm that label control causes validate event not to fire when you switch between the tabs. But this is really insane - labels are not even windows (nor are the image, line or shape controls) !!!
    Btw, frames don't help either - it must be something written within the tab control itself...

    As I said earlier "If I din't see it myself I wouldn't believe it"...
    Just another argument against using SSTab.

  16. #16
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Validate Event (Take two)

    Btw, frames don't help either - it must be something written within the tab control itself...
    Using frames solved this problem for me.

  17. #17
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Validate Event (Take two)

    Quote Originally Posted by brucevde
    Using frames solved this problem for me.
    ditto, and is indeed one of the suggested work-arounds

  18. #18
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    Strange... It didn't for me and I tried all kind of groupping on a single frame and/or multiple... no luck... It's no bother to me as I never use SSTab control (nor any control from infamous Sheridan controls library) but it's interesting enough because non-windowed control causes validation issues.

  19. #19
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Validate Event (Take two)

    Quote Originally Posted by bushmobile
    ditto, and is indeed one of the suggested work-arounds
    No, it isn't for me so it is not the solution.
    Solution (in my opinion) is to avoid using that control completely. It is convenient (because it's a container) but very buggy.

  20. #20

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Validate Event (Take two)

    Quote Originally Posted by RhinoBull
    ....Solution (in my opinion) is to avoid using that control completely....
    I will remember all the $%@%# trouble I had with this control, for now it's too late to replace it with TabStrip...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

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