This scheme
Try
SR= New StreamReader(...)
Catch ex As Exception
MsgBox(ex.Message, vbOK, "Error opening File")
GoTo wrapup
End Try
... {do things}
wrapup:
SR.Dispose()
If SR IsNot Nothing Then SR.Close()
If SR.BaseStream IsNot Nothing Then SR.Close()
Any of the three ways of closing the Streamreader-SR gives a warning that SR is used before assignment. Is there a proper way to close something you’re not sure is open?