VB script - GOTO Do Loop - possible to acheive?
Hi Programming Gurus.
I tried to do a new way of looping, that even after an exit, the loop can be entered again, without having to copy the whole do...loop area.
I've been googling on this, but nothing really worked out.People tell me it's not possible, but that's hard to believe.
Is it possible to enter a loop after exiting it?
Re: VB script - GOTO Do Loop - possible to acheive?
Hi friend,
I would suggest that the loop would be a point where the loop starts right before your do loop that you want to re-enter. If the written code does not work for your situation, then go for a Goto Loop because eventhough it is seems very easy but its working is quite complicated,since it provides more then one entrance to a loop on a flowchart.
Re: VB script - GOTO Do Loop - possible to acheive?
I provide some little more information about the looping concept
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).
Re: VB script - GOTO Do Loop - possible to acheive?
That's a good idea.
I suppose this is been used for bigger project, but I just needed a goto do-loop fast, for a few simple lines of script.
Thanks for the tip.
Re: VB script - GOTO Do Loop - possible to acheive?
There is no good reason for wanting a goto (except exceptions that need on
error as said before in VBScript) against existing code flow instructions.
You can use
Do [while loop]
Exit Do
Loop [until condition satisfies]
Select Case
do Case
Case Else
End Select
If Then
ElseIf Then
Else
End If
These all above loops also provides the same purpose.
Re: VB script - GOTO Do Loop - possible to acheive?
You may also get the relevant information about the VB Script from the MSDN library just have a look at the following link.
http://msdn.microsoft.com/en-us/library/t0aew7h6.aspx