Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Issue with GOTO

Status
Not open for further replies.

SqlHunter

Programmer
Jun 3, 2004
166
US
How can use on error goto in vbscript.because i need to jump to the last part where it picks the next file.

For Each file In f.Files


IF length_of_document_name < 10 THEN
error_descr ="Error"
error_capture_date =date
On ERROR GOTO 99

END IF

------- some other statement
------some other statement
-------some other statement
99

Next

 
SqlHunter,
[tt]
>For Each file In f.Files

>IF length_of_document_name < 10 THEN
>error_descr ="Error"
>error_capture_date =date
>[red]'[/red]On ERROR GOTO 99

>[red]'[/red]END IF
[blue]else[/blue]
>------- some other statement
>------some other statement
>-------some other statement
[blue]END IF[/BLUE]
>[red]'[/red]99

>Next
[/tt]
- tsuji
 
I can't use If else...I need to use the GOTo Type instruction becasue there if I use else then I won't be able to capture my error properly...
 
SqlHunter,

Yes, you're right. I see now better. Try this.
[tt]
For Each file In f.Files
'some other instructions
on error resume next
IF length_of_document_name < 10 THEN
error_descr ="Error"
error_capture_date =date
'some other instructions --- high risk area
if err.number<>0 then
'some other instructions
err.clear
else
'you original intended statements
'------- some other statement
'------some other statement
'-------some other statement
end if
Next
on error goto 0
[/tt]
You may have to error trap more than once if you think other spots consist of high risk and can't afford to have errors thrown up.

- tsuji
 
Correction:

The ending part should be read:
[tt]
end if
End IF
Next
[/tt]
- tsuji
 
I'm surprised that no one has just said this. You can't use GOTO in vbscript. You will have to write a bunch of branch logic.
 
Hello pkailas,

That's what I suppose I did implicit and what I would take the original poster understood and the reason why they post the question.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top