|
-
Nov 2nd, 2006, 11:19 AM
#1
Thread Starter
Hyperactive Member
[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...
-
Nov 2nd, 2006, 11:39 AM
#2
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:
Private Sub Text1_Validate(Cancel As Boolean)
If Not IsNumeric(Text1.Text) Then
Cancel = True
End If
End Sub
-
Nov 2nd, 2006, 01:00 PM
#3
Thread Starter
Hyperactive Member
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:
Private Sub txtArmoCompt_Validate(KeepFocus As Boolean)
'Assigner valeur vers variable
Dim strTempString
strTempString = txtArmoCompt.Text
'Remplace toutes les espaces par rien
strTempString = Replace(strTempString, " ", "")
'Si nombre de caractère égale à zéro
If Len(strTempString) = 0 Then
'Message d'erreur
MsgBox msgMessage31, vbInformation, msgTitre31
'Garde focus sur Textbox
KeepFocus = True
End If
End Sub
Thanks !
DubweiserTM

If your question has been answered, you can mark a thread as resolved...
-
Nov 2nd, 2006, 01:27 PM
#4
Re: Textbox_Validate (In SSTab)
Ah, that's because you replace spaces in the variable rather than in the textbox itself:
VB Code:
'if you would replace this
strTempString = Replace(strTempString, " ", "")
'with this - it should work
txtArmoCompt.Text = Replace(txtArmoCompt.Text, " ", "")
'OR do this instead:
Private Sub Text1_Validate(KeepFocus As Boolean)
If Trim(Text1.Text) = "" Then
MsgBox "Textbox is empty", vbInformation, "Error"
KeepFocus = True
End If
End Sub
-
Nov 2nd, 2006, 01:39 PM
#5
Thread Starter
Hyperactive Member
Re: Textbox_Validate (In SSTab)
 Originally Posted by RhinoBull
VB Code:
Private Sub Text1_Validate(KeepFocus As Boolean)
If Trim(Text1.Text) = "" Then
MsgBox "Textbox is empty", vbInformation, "Error"
KeepFocus = True
End If
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...
-
Nov 2nd, 2006, 01:40 PM
#6
Re: Textbox_Validate (In SSTab)
That is not possible IF focus is currently in the textbox you're validating ...
-
Nov 2nd, 2006, 01:54 PM
#7
Thread Starter
Hyperactive Member
Re: Textbox_Validate (In SSTab)
 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...
-
Nov 2nd, 2006, 02:04 PM
#8
Re: Textbox_Validate (In SSTab)
Debug it - make sure you're not setting some flags anywhere to "bypass" some logic.
-
Nov 2nd, 2006, 02:56 PM
#9
Thread Starter
Hyperactive Member
Re: Textbox_Validate (In SSTab)
 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...
-
Nov 2nd, 2006, 03:22 PM
#10
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|