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

    VbScript Form Validations

    Hi,
    In Form Validations i have used the following code:-

    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."
    End If
    txtJobCode.SetFocus
    End If

    So my problem is that my textbox which is txtJobCode does not get the setfocus again and so i get a vbScript error. I do get the my form validation MsgBox "Please enter a number for JOBCODE between 100 and 174 only." no doubt....... but the text box never gets the focus again.
    How do i do this????????
    Thanks in advance,
    New to VB......


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: VbScript Form Validations

    I'm confused.
    Your subject says "VBScript..." and you use VB syntax in the code sample.
    If your code runs inside an HTML page, you need to use the methods of the DOM (document object model). In order to set the focus to a control, call controlname.focus(). SetFocus is for VB only.


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

    Re: VbScript Form Validations

    You are using VBScripting and not Visual Basic 6.0 You have to use the Data Object Model for VBScripting for that what u have to do is u've to use
    control.Focus() for ur purpose. I think this will do the needful for u
    Happy VBScripting

    bharat



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