Error Reporting?

TMLewiss
12-15-2004, 01:49 AM
When VB encounters an error does it have a number for each error or something... Like say I want to move a file, but it is in use so I can't... is that a different error then if the file didn't exist? I want to know so that I can display an error message accordingly. One other question, is it possible to open a folder in explorer from a VB .NET program? THanks in advance for any help on this topic.

Slow-Mo
12-15-2004, 05:17 AM
Yes, there are error numbers for exceptions.

For example:

imports System.IO
....
Try
File.Move(path, path2)
Catch ex as FileNotFoundException
MsgBox("File Not Found")
Catch ex as System.IO.IOException
MsgBox(err.Number & " " & err.Description)
End Try

You can catch a specific exception, or a range of exceptions and then use Err class to get error number, error description, call stack e.t.c).

Slow-Mo
12-15-2004, 05:28 AM
Oh, and to open a folder, you can call a Shell function

ProcID = Shell("""explorer"" C:\Some Folder", AppWinStyle.NormalFocus)

TMLewiss
12-20-2004, 10:54 PM
Yes, there are error numbers for exceptions.

For example:

imports System.IO
....
Try
File.Move(path, path2)
Catch ex as FileNotFoundException
MsgBox("File Not Found")
Catch ex as System.IO.IOException
MsgBox(err.Number & " " & err.Description)
End Try

You can catch a specific exception, or a range of exceptions and then use Err class to get error number, error description, call stack e.t.c).

Is there a catch for no errors? So that if it works it does what I want after that?

Also do you know where I can find a list of the errors that vb can encounter?

Slow-Mo
12-21-2004, 05:32 AM
You can find a list of these errors in MSDN library
Look for example at this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiofileclassmovetopic.asp

There is a list of all exceptions for Move method. You can find them for any method you need.

>Is there a catch for no errors? So that if it works it does what I want after that?

The code in Catch block will be only executed if an exception occurs. If there are no exceptions, this part of code will be skipped.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum