Try Catch Block question

evad4682

Well-known member
Joined
Nov 7, 2005
Messages
55
Programming Experience
Beginner
I have a try catch block that looks like the following
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] 
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Do[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] i < num[/SIZE]
[SIZE=2]'loop through directories on a server and report the size of each[/SIZE][SIZE=2][/SIZE]
i=i+1
[SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] 
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.IO.DirectoryNotFoundException[/SIZE]
[SIZE=2]'directory not found error[/SIZE]
[SIZE=2]'*****need code to resume loop****
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE]

What I don't know how to do is to resume my loop after the directory not found error occurs. Does anybody know how to do this? Thanks in advance
 
You have to Try inside the loop if you want to loop to continue after an exception occuring inside the loop. Catch goes out of Try block and code will then continue after the End Try statement.
 
Back
Top