CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Visual Basic Form Validations

    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.


  2. #2
    Join Date
    May 1999
    Location
    India
    Posts
    9

    Re: Visual Basic Form Validations

    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





  3. #3
    Join Date
    Jan 2000
    Posts
    45

    Re: Visual Basic Form Validations

    I no i have the same problem, this might help make it focused:
    txtJobCode.text = ""


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

Featured