Micro Focus QTP (UFT) Forums
"On Error Resume Next" scope in the script. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Others (https://www.learnqtp.com/forums/Forum-UFT-QTP-Others)
+--- Thread: "On Error Resume Next" scope in the script. (/Thread-On-Error-Resume-Next-scope-in-the-script)



"On Error Resume Next" scope in the script. - Pallavi - 02-01-2012

Hi,

Please find below the attached piece of code. I was running it just to get an understanding of the functionality of "On Error Resume Next".

Code:
1.On error Resume next
2.a = 0
3.msgbox b
4.dafdsa,f,sdfsd
5.dasdgajrgjsgfjaity8w7etyeajmrhtwkjhtwhtu
6.l = 0
7.msgbox Err.Number
8.dfgdkjhgdkhgdkh67857368456834658
9.z = 0
10.msgbox Err.Number


The query here is: Does "On error Resume next" declared once at the starting of the script handles the errors at all the steps in the script
or does it take care of an error only till the succeeding step where it was defined.

As for the code above i was expecting an error at line 5 and line 8 but did not encounter any.

Regards,
Pallavi


RE: "On Error Resume Next" scope in the script. - Ankesh - 02-01-2012

Hi Pallavi,

On error Resume next" declared once at the starting of the script handles the errors at all the steps in the script

try the below code

On Error Resume next
a=0
b=5
c=b/a
msgbox Err.Number




RE: "On Error Resume Next" scope in the script. - basanth27 - 02-01-2012

The feature itself is designed to over-run all of the vb errors encountered during runtime. However, it is not a hole in the net. The feature Err.number and Err.Description add value for you to capture them during runtime. If you want to disable On Error Resume Next use the On Error Got to 0.

Code:
On error Resume next
oStr= "My test"
oLen = Lenghthy(oStr)
msgbox Err.Description
On Error Goto 0
oLen = Lenghthy(oStr)
msgbox Err.Description



RE: "On Error Resume Next" scope in the script. - rajpes - 02-03-2012

On Error Goto 0


RE: "On Error Resume Next" scope in the script. - mrajeshtnl - 02-03-2012

can any one please explain/provide a link about on error resume next?
Thanks


RE: "On Error Resume Next" scope in the script. - basanth27 - 02-07-2012

I thought the code had the right one Smile thanks for pointing out the typo.