Results 1 to 10 of 10

Thread: [RESOLVED] Textbox_Validate (In SSTab)

  1. #1

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

    Resolved [RESOLVED] Textbox_Validate (In SSTab)

    Hi everybody !

    I have some textboxes in different Tab of SSTab...

    When the focus is on textbox and I click on another Tab, is it normal that the textbox_validate is not fired ???

    CausesValidation is set to True for the SSTab and the Textboxes...

    Thanks in advance !
    DubweiserTM

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

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

    Re: Textbox_Validate (In SSTab)

    Of course it fired but following events depend on how you do your validation - you have to raise the Cancel flag:
    VB Code:
    1. Private Sub Text1_Validate(Cancel As Boolean)
    2.     If Not IsNumeric(Text1.Text) Then
    3.         Cancel = True
    4.     End If
    5. End Sub

  3. #3

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

    Re: Textbox_Validate (In SSTab)

    Here is my code, sorry some words are in french:

    When the focus is on txtArmoCompt, I can click on another Tab even if txtArCompt is empty ???

    VB Code:
    1. Private Sub txtArmoCompt_Validate(KeepFocus As Boolean)
    2.         'Assigner valeur vers variable
    3.         Dim strTempString
    4.         strTempString = txtArmoCompt.Text
    5.        
    6.         'Remplace toutes les espaces par rien
    7.         strTempString = Replace(strTempString, " ", "")
    8.        
    9.         'Si nombre de caractère égale à zéro
    10.         If Len(strTempString) = 0 Then
    11.                 'Message d'erreur
    12.                 MsgBox msgMessage31, vbInformation, msgTitre31
    13.                 'Garde focus sur Textbox
    14.                 KeepFocus = True
    15.         End If
    16. End Sub

    Thanks !
    DubweiserTM

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

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

    Re: Textbox_Validate (In SSTab)

    Ah, that's because you replace spaces in the variable rather than in the textbox itself:
    VB Code:
    1. 'if you would replace this
    2. strTempString = Replace(strTempString, " ", "")
    3.  
    4. 'with this - it should work
    5. txtArmoCompt.Text = Replace(txtArmoCompt.Text, " ", "")
    6.  
    7. 'OR do this instead:
    8. Private Sub Text1_Validate(KeepFocus As Boolean)
    9.     If Trim(Text1.Text) = "" Then
    10.         MsgBox "Textbox is empty", vbInformation, "Error"
    11.         KeepFocus = True
    12.     End If
    13. End Sub

  5. #5

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

    Re: Textbox_Validate (In SSTab)

    Quote Originally Posted by RhinoBull
    VB Code:
    1. Private Sub Text1_Validate(KeepFocus As Boolean)
    2.     If Trim(Text1.Text) = "" Then
    3.         MsgBox "Textbox is empty", vbInformation, "Error"
    4.         KeepFocus = True
    5.     End If
    6. End Sub
    I tried with this, I can't go on another textbox but I can go on another TAB ???
    DubweiserTM

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

  6. #6

  7. #7

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

    Re: Textbox_Validate (In SSTab)

    Quote Originally Posted by RhinoBull
    That is not possible IF focus is currently in the textbox you're validating ...
    You're ok !

    I started a new project and I put a SSTab and 2 textboxes, and I can't go to another Tab...

    I dont know why in my program I can ???
    DubweiserTM

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

  8. #8

  9. #9

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

    Re: Textbox_Validate (In SSTab)

    Quote Originally Posted by RhinoBull
    Debug it - make sure you're not setting some flags anywhere to "bypass" some logic.
    Sorry for this newbie question: What is flags ???

    Thanks !
    DubweiserTM

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

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

    Re: Textbox_Validate (In SSTab)

    Those are just variables - could be any type but mostly Integer and/or Boolean.
    If you need to omit (or instead excute) certain part in your program you will raise "flag" like intIgnore = 1 or blnIgnore = True and when specific logic is finish excuting then you will reset it back to 0(ZERO) or False.
    That's a very common programming technic.

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