is there a way of using 'goto' in vbscript?
Printable View
is there a way of using 'goto' in vbscript?
The only Goto supported in VBScript is with error handling:
Code:On Error Goto 1
so is there any way of getting Call...Sub?
what do you mean?
for example:
Code:if cheese = 0 then call bob
sub bob
msgBox "hello"
I'm not aware of a goto function but you can call subroutines and functions:
HTHCode:Sub MySub
'Do stuff here
End Sub
Call MySub
DJ
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.