Click here to Skip to main content
15,915,873 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: ms installer Pin
Christian Graus7-Oct-06 23:53
protectorChristian Graus7-Oct-06 23:53 
QuestionRe: ms installer Pin
steve_rm8-Oct-06 4:08
steve_rm8-Oct-06 4:08 
QuestionReading cursor position with a timer Pin
re infecta7-Oct-06 22:17
re infecta7-Oct-06 22:17 
AnswerRe: Reading cursor position with a timer Pin
Christian Graus7-Oct-06 23:42
protectorChristian Graus7-Oct-06 23:42 
Questionwhat is this Pin
Xmen Real 7-Oct-06 17:51
professional Xmen Real 7-Oct-06 17:51 
AnswerRe: what is this Pin
Guffa7-Oct-06 20:12
Guffa7-Oct-06 20:12 
GeneralRe: what is this Pin
Xmen Real 7-Oct-06 20:23
professional Xmen Real 7-Oct-06 20:23 
AnswerRe: what is this Pin
Guffa7-Oct-06 23:11
Guffa7-Oct-06 23:11 
You are catching the exception and ignoring it. Never do that! (Notice the exclamation mark that I used. I use less than a dozen per year, so when I do, they mean something.) If you don't know what to do with it, just throw it again, so that some higher level of the program can catch it.

Also, your error handling doesn't make sure that the files are closed if an error occurs. I believe that the error message that you see comes from some other part of your program when it tries to use a file that has been left open by the function.

Use Try and Finally to make sure that the files are always closed:

Dim fSave
Try
	fSave = As New StreamWriter(fName)
	fSave.WriteLine("# File Created By ABC")
	fSave.WriteLine(value1)
Finally
	If not fSave is Nothing Then
		fSave.Close()
	End If
End Try


You can add a Catch section before the Finally to handle any exception that occurs in this specific part of the code, or wrap all the code in the function inside a Try ... Catch to take care of any exception that occurs anywhere in the function.




---
b { font-weight: normal; }

GeneralRe: what is this Pin
Xmen Real 7-Oct-06 23:42
professional Xmen Real 7-Oct-06 23:42 
AnswerRe: what is this Pin
Guffa8-Oct-06 0:05
Guffa8-Oct-06 0:05 
GeneralRe: what is this Pin
Xmen Real 8-Oct-06 0:13
professional Xmen Real 8-Oct-06 0:13 
AnswerRe: what is this Pin
Guffa8-Oct-06 2:07
Guffa8-Oct-06 2:07 
Questionhow to make an application to program Pin
Xmen Real 7-Oct-06 17:45
professional Xmen Real 7-Oct-06 17:45 
AnswerRe: how to make an application to program Pin
nlindley77-Oct-06 18:26
nlindley77-Oct-06 18:26 
GeneralRe: how to make an application to program Pin
Xmen Real 7-Oct-06 19:16
professional Xmen Real 7-Oct-06 19:16 
GeneralRe: how to make an application to program Pin
Christian Graus7-Oct-06 23:39
protectorChristian Graus7-Oct-06 23:39 
GeneralRe: how to make an application to program Pin
Dave Kreskowiak8-Oct-06 2:18
mveDave Kreskowiak8-Oct-06 2:18 
QuestionToolstripcomboBox Pin
Socheat.Net7-Oct-06 16:34
Socheat.Net7-Oct-06 16:34 
AnswerRe: ToolstripcomboBox Pin
nlindley77-Oct-06 18:21
nlindley77-Oct-06 18:21 
GeneralRe: ToolstripcomboBox Pin
Socheat.Net10-Oct-06 17:45
Socheat.Net10-Oct-06 17:45 
QuestionVB Cleanup Program - In (Context Menu) SendTo Pin
RickMagenta7-Oct-06 6:52
RickMagenta7-Oct-06 6:52 
AnswerRe: VB Cleanup Program - In (Context Menu) SendTo Pin
Ray Cassick7-Oct-06 16:13
Ray Cassick7-Oct-06 16:13 
GeneralRe: VB Cleanup Program - In (Context Menu) SendTo Pin
RickMagenta8-Oct-06 0:12
RickMagenta8-Oct-06 0:12 
Questionhow to make a layout designer in crystal report without using wizard Pin
vidyashankar7-Oct-06 4:58
vidyashankar7-Oct-06 4:58 
QuestionHow to solve it? Pin
aloksingh20067-Oct-06 2:07
aloksingh20067-Oct-06 2:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.