|
-
Jun 24th, 2000, 12:11 PM
#1
Thread Starter
Addicted Member
I wrote this code:
Private Sub txtName_LostFocus()
Call CheckTextValidation(txtName)
End Sub
Public Function CheckTextValidation(txt As TextBox) As Boolean
If txt.Text = Empty Then
Call MsgBox("you should insert data to this field", vbExclamation + vbOKOnly, App.Title)
CheckTextValidation = False
Else
CheckTextValidation = True
End If
End Function
But ,it doesn't work properly after it display the first
msgbox and i clicked OK it display the msgbox AGAIN !!!
PLEASE HELP
The MORE I get to know,
I realize that I know NOTHING !
-
Jun 24th, 2000, 12:17 PM
#2
Hyperactive Member
Give the focus back
You see, you have to give the focus back to the textbox, otherwise vb will just keep running that code.
use something like
and put it after you've showed the msgbox

[Edited by Rodik on 06-25-2000 at 01:19 AM]
Signed, Rodik ([email protected])
Programmer,usesVB6ED
===========================
Copyright©RodikCo,2002.
Dont mind this signature ;] Its old
-
Jun 24th, 2000, 12:26 PM
#3
Thread Starter
Addicted Member
well,I did it ,but still it doesn't work
Public Function CheckTextValidation(txt As TextBox) As Boolean
If txt.Text = Empty Then
Call MsgBox("xxxxxxxxxxx", vbExclamation + vbOKOnly, App.Title)
CheckTextValidation = False
----> txt.SetFocus <----
Else
CheckTextValidation = True
End If
End Function
The MORE I get to know,
I realize that I know NOTHING !
-
Jun 24th, 2000, 10:54 PM
#4
PowerPoster
Originally posted by lirlir
I wrote this code:
Private Sub txtName_LostFocus()
Call CheckTextValidation(txtName)
End Sub
Public Function CheckTextValidation(txt As TextBox) As Boolean
If txt.Text = Empty Then
Call MsgBox("you should insert data to this field", vbExclamation + vbOKOnly, App.Title)
CheckTextValidation = False
Else
CheckTextValidation = True
End If
End Function
But ,it doesn't work properly after it display the first
msgbox and i clicked OK it display the msgbox AGAIN !!!
PLEASE HELP
If you only need to validate the text inside a textbox control, you actually no need to pass the entire TextBox control into your CheckTextValidation function. All you need is...
Code:
Private Sub txtName_LostFocus()
If CheckTextValidation (txtName.Text) then
'Proceed what you need to do
Else
'Proceed to do something else...
End If
End Sub
Public Function CheckTextValidation(txt As String) As Boolean
If txt = "" Then
MsgBox "you should insert data to this field", vbExclamation + vbOKOnly, App.Title
CheckTextValidation = False
Else
CheckTextValidation = True
End If
End Function
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
|