473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Try - Catch Sample Programs

pbala
37
Hello sir,
Please Give me any examples of Exception Handling Techniques in VB.Net 2005.

Thanks sir.....
Dec 16 '08 #1
4 2380
lotus18
866 512MB
@pbala
Here is one example on how to display help contents.
Expand|Select|Wrap|Line Numbers
  1.  
  2. Try
  3.    'Check if the there is Help.chm
  4.    'Help.ShowHelp(Me, Application.StartupPath & "\Help.chm") Or
  5.    System.Diagnostics.Process.Start(Application.StartupPath & "\Help.chm")
  6. Catch ex As Exception
  7.    'Display error message if the file is not found
  8.    MessageBox.Show(ex.Message, "Help", MessageBoxButtons.OK, MessageBoxIcon.Error)
  9. End Try


Rey Sean
Dec 16 '08 #2
sashi
1,754 Expert 1GB
You try to catch, you catch and you throw :)
Dec 22 '08 #3
There is another option for Try....Catch Blocks. It is finally:

Expand|Select|Wrap|Line Numbers
  1. Try
  2. 'Put your code in here
  3. Catch nex as NullReferenceException
  4.    'This is how you can catch specific types of exceptions and handle them separately.
  5. Catch ex as Exception
  6.    'If you do not specify an exception type then this will catch it.  Kind of an all 
  7.    '  purpose catchers mitt.
  8. Finally
  9.     'This is nifty, anything put into this section will run REGARDLESS of any errors that are caught.  
  10.     'This is especially helpful for objects declared outside of the try catch block like FileStreams or data objects 
  11.     'because you can handle and dispose of them properly here instead of having to code/recode in several areas.
  12. End Try
  13.  
Dec 24 '08 #4
MrMancunian
569 Expert 512MB
@sashi
This explaination isn't entirely true. You don't try to catch. You should see it as a safety harnass. You jump to get to the other side, but when you fall, there is a safety harnass as a catch.

Expand|Select|Wrap|Line Numbers
  1. Try 'Jump to get to the other side
  2.  
  3. Catch 'If you don't make it, this is your safety harnass
  4.   MessageBox(ex.Message) 'Why didn't you complete the jump?
  5. Finally 'Whether you complete the jump or not, you can get into your car and drive home
  6.  
  7. End Try 'Welcome home!
  8.  
Dec 27 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
8
by: Peter Nolan | last post by:
Hi All, I have written some software that performs ETL processing to load data warehouses. Each program accepts a set of parameters and returns 0 or 1 to the win/unix shell to indicate success or...
4
by: nrhayyal | last post by:
hi all, i am facing a problem in catching an exception which is uncaught in any of the catch block. not doing so will gives me coredump. I tried by rewriting set_unexpected() and set_terminate()...
1
by: Rhino | last post by:
What is the correct way to notify the tech writers that one of the sample programs has errors in it? Unless I am mistaken, there is an error in the DtLob.java program in the V8.1 Java/JDBC...
2
by: Martin Wingelaar | last post by:
I would like to play around with BLOB and CLOB's and need the sample programs compiled by DSNTEJ71, DSNTEJ73 and DSNTEJ75. The problem is I don't have a C/C++ compiler. Could anyone send me the...
37
by: clintonG | last post by:
Has somebody written any guidelines regarding how to determine when try-catch blocks should be used and where their use would or could be considered superfluous? <%= Clinton Gallagher...
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
3
by: will | last post by:
Hi all. I've got an question about how to catch an exception. In Page_Load, I place a DataGrid, dg1, into edit mode. This will call the method called GenericGridEvent. GenericGridEvent will call...
11
by: l.woods | last post by:
I want to set up my CATCH for a specific exception, but I really don't know which one of the multitude that it is. I am getting the exception now with Catch ex as Exception but I want to be...
10
by: www.hitechskill.com | last post by:
HiTechSkill.Com offers free information, tests, and sample interview questions that will help to improve your information technology skills. http://www.hitechskill.com
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.