Click to See Complete Forum and Search --> : Visual Basic Form Validations


January 19th, 2000, 11:48 PM
Hi,
How do i set the focus back onto a textbox
eg : I am using the following code in my Visual Basic project

If IsNumeric(txtJobCode.Text) Then
If txtJobCode.Text < 100 Or txtJobCode.Text > 174 Then
MsgBox "Please enter a number for JOBCODE between 100 and 174 only."
txtJobCode.SetFocus
End If
End If

I do get the message box but i never get the setfocus back onto the textbox
Please Help,
New to Visual basic.
PS : This is not VBScript in html but i am working on a visual basic project. ;)

bharat
January 20th, 2000, 12:38 AM
i think ur code is perfect the problem may be u may have more codes after this set in the same procedure so u have to say exit sub after setting the focus so the procedure stops there. iam sending u the corrected code okay. also tell me where r u writing this code in which event(is it lostfocus of the text box)

If IsNumeric(txtJobCode.Text) Then
If txtJobCode.Text < 100 Or txtJobCode.Text > 174 Then
MsgBox "Please enter a number for JOBCODE between 100 and 174 only."
txtJobCode.SetFocus
exit sub
End If
End If

Starcraft
January 20th, 2000, 11:58 AM
I no i have the same problem, this might help make it focused:
txtJobCode.text = ""