Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"On Error Resume Next" scope in the script.
#1
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Reply
#2
Solved: 11 Years, 3 Months, 3 Weeks ago
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

Reply
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
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
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#4
Solved: 11 Years, 3 Months, 3 Weeks ago
On Error Goto 0
Reply
#5
Solved: 11 Years, 3 Months, 3 Weeks ago
can any one please explain/provide a link about on error resume next?
Thanks
Reply
#6
Solved: 11 Years, 3 Months, 3 Weeks ago
I thought the code had the right one Smile thanks for pointing out the typo.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VB Script access denied error when executing alm scripts in planned host Kumar Reshma 0 1,531 05-28-2018, 04:04 PM
Last Post: Kumar Reshma
  Windows 8 envirnment error while running QTP script. Rashmi Rajpal 0 2,444 10-10-2013, 12:21 PM
Last Post: Rashmi Rajpal
  qtp resume help me shyam.emmadi 0 2,222 04-21-2011, 03:00 PM
Last Post: shyam.emmadi
  Run the QTPTest script from the Quality Center then an error occurs shivakumar6g 8 12,773 03-04-2011, 11:52 AM
Last Post: shivakumar6g

Forum Jump:


Users browsing this thread: 1 Guest(s)