dcsimg
Results 1 to 7 of 7

Thread: [Resolved] Is there a [goto] function in vbscript?

  1. #1

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Resolved [Resolved] Is there a [goto] function in vbscript?

    is there a way of using 'goto' in vbscript?
    Last edited by ajames; Apr 12th, 2005 at 11:28 AM.

  2. #2
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Is there a [goto] function in vbscript?

    The only Goto supported in VBScript is with error handling:
    Code:
    On Error Goto 1
    "I don't want to live alone until I'm married" - M.M.R.P

  3. #3

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Is there a [goto] function in vbscript?

    so is there any way of getting Call...Sub?

  4. #4
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Is there a [goto] function in vbscript?

    what do you mean?
    "I don't want to live alone until I'm married" - M.M.R.P

  5. #5

    Thread Starter
    Addicted Member ajames's Avatar
    Join Date
    Mar 2005
    Location
    Wales, UK
    Posts
    178

    Re: Is there a [goto] function in vbscript?

    for example:
    Code:
    if cheese = 0 then call bob
    sub bob
    msgBox "hello"

  6. #6
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: Is there a [goto] function in vbscript?

    I'm not aware of a goto function but you can call subroutines and functions:
    Code:
    Sub MySub
    'Do stuff here
    End Sub
    
    Call MySub
    HTH

    DJ

    If I have been helpful please rate my post. If I haven't tell me!

  7. #7
    New Member
    Join Date
    Jul 2011
    Posts
    1

    Post Re: [Resolved] Is there a [goto] function in vbscript?

    In short, no. GoTo exists, but it cannot be used like this:

    START:

    GoTo START


    It's use in VBScript is limited to error handling. Error handling is 'turned on' like this:

    On Error Resume Next

    (This has nothing to do with the For ... Next loop by the way). And turned off like this:

    On Error GoTo 0

    That's it. As you may know, the GoTo keyword is not required and all things that can be programmed with it can be programmed without it. Personally I think the option should be there for those of us who understand its uses and are intelligent enough not to create spaghetti code, but there we are.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width