Click here to Skip to main content
15,914,413 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Data type conversion into VB Pin
Instamatix9-Nov-06 22:55
Instamatix9-Nov-06 22:55 
QuestionHow do you Split Intallation files -VS2005? Pin
RichardBerry9-Nov-06 20:56
RichardBerry9-Nov-06 20:56 
AnswerRe: How do you Split Intallation files -VS2005? Pin
Dave Kreskowiak10-Nov-06 2:36
mveDave Kreskowiak10-Nov-06 2:36 
GeneralRe: How do you Split Intallation files -VS2005? Pin
RichardBerry10-Nov-06 2:50
RichardBerry10-Nov-06 2:50 
GeneralRe: How do you Split Intallation files -VS2005? Pin
Dave Kreskowiak10-Nov-06 13:47
mveDave Kreskowiak10-Nov-06 13:47 
QuestionTry Catch - Best Practice - How much code should be inside Pin
RichardBerry9-Nov-06 20:49
RichardBerry9-Nov-06 20:49 
AnswerRe: Try Catch - Best Practice - How much code should be inside Pin
Cmania9-Nov-06 22:03
Cmania9-Nov-06 22:03 
AnswerRe: Try Catch - Best Practice - How much code should be inside Pin
Guffa10-Nov-06 0:02
Guffa10-Nov-06 0:02 
RichardBerry wrote:
1) How does a try catch block function? Could you relate it in any way to the following:

If (exception occurs while doing something) then

Goto Catch

else

Contine executing

Endif


Well, have a you look at a Try...Catch with multiple catches and a Finaly block:

Try
	... do something that might fail
Catch IOException ex
	... handle the specific exception
Catch Exception ex
	... handle all other .NET exceptions
Catch
	... handle any other exception
Finally
	... always runs
End Try

If any exception is raised in the Try block, execution immediately goes to the first Catch block where the type of the exception matches. An IOException would be handled by the Catch IOException block, but an ArgumentNullException would be handled by the Catch Exception block (as ArgumentNullException inherits from Exception). If you are calling an external library it might throw non-.NET exceptions, they would go to the Catch block.

The Finally block is used to make sure that anything used in the Try block is closed and disposed properly. The Finally block always runs, regardless if there was an exception or not.


RichardBerry wrote:
2) What is good practice with respect to the amount of code inside a Try .. Catch Block. Is it bad to have a lot of code (why?) and is is bad to call another procedure from withing a Try Catch Block


There are two uses for Try...Catch blocks; wide and narrow. A wide block can be used to handle any exceptions from an entire application, or from a section of an application. A narrow block should be used to handle the specific exceptions that you anticipate might occur, and they should surround as little code as possible.

You can't write code to specifically handle any exception that possibly can occur, so use narrow blocks to catch the ones that you anticipate, and wide block to catch anything unexpected.


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

GeneralRe: Try Catch - Best Practice - How much code should be inside Pin
RichardBerry10-Nov-06 2:48
RichardBerry10-Nov-06 2:48 
QuestionCreate Folder Pin
Sinchan Nikam9-Nov-06 20:05
Sinchan Nikam9-Nov-06 20:05 
AnswerRe: Create Folder Pin
Cmania9-Nov-06 21:53
Cmania9-Nov-06 21:53 
QuestionDifference between Chr() and Chr$() Pin
Cmania9-Nov-06 18:28
Cmania9-Nov-06 18:28 
AnswerRe: Difference between Chr() and Chr$() Pin
Dave Kreskowiak10-Nov-06 2:17
mveDave Kreskowiak10-Nov-06 2:17 
GeneralRe: Difference between Chr() and Chr$() Pin
nlarson1110-Nov-06 3:47
nlarson1110-Nov-06 3:47 
GeneralRe: Difference between Chr() and Chr$() Pin
Dave Kreskowiak10-Nov-06 6:00
mveDave Kreskowiak10-Nov-06 6:00 
GeneralRe: Difference between Chr() and Chr$() Pin
Cmania12-Nov-06 19:10
Cmania12-Nov-06 19:10 
Questionconverting VS2003 created sample to VS2005 giving debugger error Pin
GnanaprakashJebaraj9-Nov-06 17:43
GnanaprakashJebaraj9-Nov-06 17:43 
Questioncombo box getting a PK from a selected item Pin
steve_rm9-Nov-06 17:28
steve_rm9-Nov-06 17:28 
AnswerRe: combo box getting a PK from a selected item Pin
Dave Kreskowiak10-Nov-06 2:19
mveDave Kreskowiak10-Nov-06 2:19 
AnswerRe: combo box getting a PK from a selected item Pin
steve_rm10-Nov-06 3:20
steve_rm10-Nov-06 3:20 
QuestionUsing COM object created by MatLab Pin
Dhanushka P9-Nov-06 16:12
Dhanushka P9-Nov-06 16:12 
AnswerRe: Using COM object created by MatLab Pin
b43r_3oo39-Nov-06 18:12
b43r_3oo39-Nov-06 18:12 
QuestionHow can I rename treenode text! Pin
Lanmiu_ith9-Nov-06 15:10
Lanmiu_ith9-Nov-06 15:10 
AnswerRe: How can I rename treenode text! Pin
b43r_3oo39-Nov-06 18:15
b43r_3oo39-Nov-06 18:15 
QuestionVB.NET/ASP.NET 2005 Designer Selection Pin
Luke R9-Nov-06 14:37
Luke R9-Nov-06 14:37 

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.