Handling an exception in Visual Basic?

I have the following happening:

Timer1 is set to at every interval, to use code:
richtextbox.loadfile (file path)
so the rich text box in my program constantly refreshes to say what the file in the path contains, however, for some periods the folder the file is in becomes unavailable for a short moment (due to another program using the folder) and of course this causes the Unhandeled Exception "File Not Found" error to appear.

How do I code the program so when this exception occurs it'll do something for example: textbox1.text = "text here"
or
form2.show

Using VB 2005

Gardner2013-01-24T21:03:55Z

Favorite Answer

Try
richtextbox.loadfile(yourfile)
Catch e as Exception
richtextbox.AppendText(e.Message)
End Try

This will write the error message into your textbox.

Anonymous2016-10-18T14:41:26Z

inner most Sub RTBload_btn_Click(ByVal.... attempt RTB1.LoadFile(your filepath, or var ) capture ex as exception MSGBox("The requested FilePath can't be discovered") go out Sub end attempt end Sub ' this can forestall the kind from preventing at an exception. ' no longer certain if go out Sub is major. attempt with out it first, if the shape loops, then upload it.