Goto on vbscript

Discussion in 'Scripting' started by Jrex7, Nov 4, 2005.

  1. Jrex7

    Jrex7 Guest

    Is there a way to jump inside a vbscript the same way you do in a batch file
    by using goto?

    What I need to do is rerun a script when it gets to the end based on a

    On my script I am searching for user information. If the username entered by
    the operator does not exist I want to rerun the script from the begining
    without starting a second process. This requirements exists because I am
    running the script from published applicaion on a citrix server.

    Any help with this question is appreciated.
    Jrex7, Nov 4, 2005
    1. Advertisements

  2. Why don't you use a loop for this

    do while x=y
    'Code Here

    gr /\/\o\/\/
    /\\/\\o\\/\\/, Nov 4, 2005
    1. Advertisements

  3. Jrex7

    MoiToo Guest

    I agree, use for/next or do while next...

    But, if you do need the jumping, there is a way in VB - I assume it works in
    VBS also.

    msgbox "Begin"
    if err.description <> nothing goto Errorhandler

    msgbox "No error"
    exit function

    Errorhandler :
    msgbox "Error Handled"

    This would take you to the Errorhandler, when there has been an error,
    otherwise it won't go to the sub. (Obviously, change to if err.description
    =nothing goto Errorhandler to test functionality).

    As you can see, this has severly limited options - which is why the for/next
    is better.
    MoiToo, Nov 5, 2005
  4. Jrex7

    Jrex7 Guest

    Thank you Mow and Moi for your reply.
    Let me give more information so that maybe you can show me another way if
    there is to do what I want.

    When the script in question here finishes running it displays the reults for
    the user name that was entered for a query. Then the user can close the
    window with an ok button.
    I want to give the users of this script the ability to search again for
    another user name with a Window that says "Do you want to Search again"
    If the user clicks ok the script would start from the begining. If the user
    cliks no, the script shoud just close.

    I had added the following code to recall the same script from the end but
    when I click "yes" the script just closes.

    Can you either tell me what I am doing wrong here of show me a way to do it

    Thank you again.
    Jrex7, Nov 7, 2005
  5. Jrex7

    Jrex7 Guest

    Thank you, for your input on this.
    I looked at my script again and found that the Do...While Loop was not
    working because a Select Case statement was wrong and the variable used on
    the loop was not changing.
    Jrex7, Nov 8, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.