Dim OutFile As System.IO.StreamWriter
OutFile = Nothing
Try
OutFile = New System.IO.StreamWriter(Filename)
// Do stuff with OutFile
Catch Ex As Exception
// Handle Exception
Finally
If OutFile IsNot Nothing Then OutFile.Close()
End Try
Similar to C# error: Use of unassigned local variable