Student Mode Code Display

Welcome to the Fraternity!

Commenting has been enabled. You can comment on all the Code Items now.

All about Error Handling


Add This Code to My Favourite List
Enter Email

Contributed By IT Prof
Date 2016-03-20 01:36:28

'Tutorial: itprof_tut
'Detail: ' This will not give error as error handling of function 1 is inherited in the called functions.
'Author: Akash

On Error Resume Next
Err.Raise 6   ' Raise an overflow error.
MsgBox "Error # " & CStr(Err.Number) & " " & Err.Description
Err.Clear   ' Clear the error.


'Calling Function
'This will not give error as error handling of function 1 is inherited in the called functions.
Call Fnc_1

'Function 1 definition
Function Fnc_1
      On error resume Next ' enable error handling here
	Call Fnc_2
End Function

'Function 2 definition
'No Error handling here
Function Fnc_2
   Call Fnc_3
	msgbox 1' this line will not be executed.
					' becoz no error handling in the Function
					' but there will not be any error pop up as well

End Function

'Function 3 definition
'No err
Function Fnc_3

	Dim temp, temp1
	Dim result
	
	temp = 1
	temp1 = 0
	
	result = temp/temp1 ' generating 1/0 exception.
	msgbox 1' this line will not be executed.
			        ' becoz no error handling in the Function
					'but there will not be any error pop up as well
End Function

Download Above Code

Comments:



Add your comments...
Name : *      
Email : *      
The content of this field will be kept private and will not be shown publicly

Your Comment/Answer *

Enter the text present in this box : *