jyothi_priya
13 years agoContributor
Goto in VBScript
Hi,
I want following kind of code in VBScript:
Function ClickControl(Object,Label)
If Object.Exists Then
Object.Click()
Else
Goto Label
End If
End Function
Sub T1
XXX = NameMapping.Sys.Process("XXX")
Call ClickControl(XXX,L1)
L1: End Sub
Sub T2
YYY = NameMapping.Sys.Process("YYY")
Call ClickControl(YYY,L2)
L2: End Sub
I know we can return values from function and can use If conditions. But this won't help me as there are many click operations in one sub routine and using If conditions that many times will be very tidious and script wont look neat.
Can't I use Goto like above in VBScript?
I want following kind of code in VBScript:
Function ClickControl(Object,Label)
If Object.Exists Then
Object.Click()
Else
Goto Label
End If
End Function
Sub T1
XXX = NameMapping.Sys.Process("XXX")
Call ClickControl(XXX,L1)
L1: End Sub
Sub T2
YYY = NameMapping.Sys.Process("YYY")
Call ClickControl(YYY,L2)
L2: End Sub
I know we can return values from function and can use If conditions. But this won't help me as there are many click operations in one sub routine and using If conditions that many times will be very tidious and script wont look neat.
Can't I use Goto like above in VBScript?
- Hi,
There is no GoTo label statement in VBScript. The GoTo keyword is used only as part of the On Error statement for disabling error handling, as follows:
To control the test execution flow, you'll need to use If..Then..Else, Select..Case and other flow control statements.