Tips and Tricks of Error Handling in VBScript or in UFT

80
3238
Spread the love
  • 24
  • 28
  • 12
  • 23
  •  
  •  
  •  
  •  
  •  
  •  
    87
    Shares

Tips and Tricks of Error Handling in VBScript or in UFT
Tips and Tricks of Error Handling in VBScript or in UFT

Error Handling in VBScript or in UFT:

Errors are something which is a resultant of deviation from the assumption or requirement or rules via code.It may happen due to syntax mismatch,invalid user input or unavailability of system resources.

Errors in VBScript or UFT are broadly classified as

  • Syntax Error
  • Runtime Error
  • Logic Error

Syntax Error aka Compilation Error

Every language follow a set of guidelines,rules,semantics etc. VBscript is also a language which has a set of rules,guidelines,semantics. Before or during executing a piece of code, VBScript engine checks the piece of code code for the validity of those by parsing them and converting into tokens.In case VBScript engine encounters an unrecognizable code or expression, it flags the line as syntax error.

VBscript halts the code execution due to the syntax error. VBScript engine reads the script file and tries to parse the code by converting into meaningful tokens. During this process, if the VBScript engine finds some unacceptable code format due to unrecognizable structure or expressions, it points out this as compilation error or Syntax error.

Syntax error is often coined as

  • Pre-processor error
  • Compilation error
  • Compile time error

Example of Syntax error:


Dim myMarks
myMarks=66
If (myMarks>60)
msgbox "Kudos you got 1st division"
End If
 

output:
ErrorCode:800A03F9
Error: Expected Then
Line-3
Character-16

Now as the WSH provides clear error details, it is very easy to detect and rectify the Syntax errors.

VBscript does not support conditional compilation(an ability to execute different code base on different environments)

Why Syntax Error Occurs?

Below are the prime reasons why Syntax Error happens:

  • If we miss providing mandatory structure information(like keywords, blocks, commas, parenthesis etc)
  • Spelling mistake while using variables, procedures calls, function calls or expressions.
  • Keywords related to other Microsoft tools(Excel, VBA etc) which are not supported by VBScript.
  • Functions related to other Microsoft tools(Excel, VBA etc) which are not supported by VBScript. Mostly these functions need to be defined before using.
  • VBScript has backward compatibility hence versions generally do not play a major role in a Syntax error. But Script written in higher VBScript version may not work well in the lower VBScript versions.
  • Dynamic code generation and execution creates a huge problem in VBScript(command like ExecuteGlobal, Execute or Eval needs extra care).
Common Syntax Error with Error code an Description

 

Hexadecimal Error Code Decimal Error Code Comments
800A03E9 1001 “Out of memory” error.
800A040F 1039 “Invalid ‘exit’ statement” error.
800A03EA 1002 “Syntax” error.
800A0410 1040 “Invalid ‘for’ loop control variable” error
800A03ED 1005 “Expected ‘(‘ ” error.
800A0411 1041 “Name redefined” error.
800A03EE 1006 “Expected ‘)’ ” error.
800A0412 1042 “Must be first statement on the line” error.
800A03F2 1010 “Expected identifier” error.
800A0414 1044 “Cannot use parentheses when calling a Sub” error.
800A03F3 1011 Expected ‘=’ error.
800A03F4 1012 Expected ‘If’ error.
800A0415 1045 “Expected literal constant” error.
800A03F5 1013 “Expected ‘To’ ” error.
800A0416 1046 “Expected ‘In’ ” error.
800A03F6 1014 “Expected ‘End’ ” error.
800A0418 1048 “Must be defined inside a Class” error.
800A0417 1047 “Expected ‘Class’ ” error.
800A03F7 1015 “Expected ‘Function’ “error.
800A0419 1049 “Expected Let , Set , or Get in property
declaration” error.
800A03F8 1016 “Expected ‘Sub’ ” error.
800A03F9 1017 “Expected ‘Then’ ” error.
800A041A 1050 “Expected ‘Property’ ” error.
800A03FA 1018 “Expected ‘Wend’ ” error.
800A041B 1051 “Number of arguments must be consistent across properties specification” error
800A03FB 1019 “Expected ‘Loop’ ” error.
800A041C 1052 “Cannot have multiple default property/method in a Class” error,
800A03FC 1020 “Expected ‘Next’ ” error.
800A041D 1053 “Class initialize or terminate do not have arguments” error.
800A03FD 1021 “Expected ‘Case’ ” error.
800A041E 1054 “Property Set or Let must have at least one argument” error.
800A03FE 1022 “Expected ‘Select’ ” error.
800A041F 1055 “Unexpected ‘Next’ ” error.
800A03FF 1023 “Expected expression” error.
800A0421 1057 ” ‘Default’ specification must also specify ‘Public’ ” error.
800A0400 1024 “Expected statement” error.
800A0422 1058 ” ‘Default’ specification can only be on property Get” error.
800A0401 1025 “Expected end of statement” error.
800A0402 1026 “Expected integer constant” error.
800A0403 1027 “Expected ‘While’ or ‘Until’ ” error.
800A0404 1028 “Expected ‘While’, ‘Until’, or end of statement” error.
800A0405 1029 “Expected ‘With’ ” error.
800A0406 1030 “Identifier too long” error.
800A0407 1013 “Invalid number” error.
800A0408 1014 “Invalid character” error.
800A0409 1015 “Undermined string constant” error
800A040A 1034 “Undermined comment” error.
800A040D 1037 “Invalid use of ‘Me’ keyword” error.
800A040E 1038 “‘loop’ without ‘do’ “error.
800A03EB 1003 “Expected :” error.
800A040E 1007 “Expected ]” error
800A040E 1031 “Invalid number” error
800A040E 1043 “Can not assign to non-ByVal argument” error
800A0420 1056 “”‘Default’ can be specified only on ‘Property’ or ‘Function’ or ‘sub’ ” error

Runtime Error:

A runtime error occurs when we try to perform a command on an invalid action. These codes get compiled as there is not a Syntax error but failed in the runtime and generate a Runtime error. Runtime errors are not the same as Syntax errors. Here the source information always is “Microsoft VBScript runtime error.”

Runtime errors are not easily detected during the development time of the script.

Why runtime error occurs?

  • Based on certain security option’s enabled or disabled property.
  • The used components are either down or not available.
  • The execution platform may be different or other than script developed environment.
  • Mismatch in script configuration.
  • The executing box may be under tremendous stress or load.

Runtime errors can be classified as:

  • Non VBScript Runtime error
  • Native VBScript runtime error
  • Variable declaration related due to Option Explicit runtime error.

Non-VBScript Runtime Error

These runtime errors are not generated by the VBScript engine. They are generated by some other components which are attached to VBScript.

Like ADO,ActiveX,DataObject etc..

Common Non VBScript Runtime error codes:

Sl no Expression Meaning
1 8007XXXX Windows error
2 800AXXXX ADO Error
3 8005XXX ADSI Error

Native VBScript Runtime Error

Native VBScript runtime error happens when the user performs some illegal operations. Mostly these errors are recorded and stored in VBScript Engine.
These errors happen when:

  • One performs wrong arithmetic operations.
  • Read from a database having a null value
  • Keep reading even after the control reached at the End of File.
  • Wrongly used Null in the expressions.
Example of Native Runtime Error

Option Explicit
Dim myVar
myVar=10/0
msgbox "The result is"+ myVar
 

Output:
ErrorCode-800A000B
Error-Division by zero
Line-4
Character-1

Example of Native Runtime Error

Dim myVar
myVar=Null
msgbox "The result is"+ myVar
 

Output:
ErrorCode-800A005E
Error-Invalid Use of Null
Line-4
Character-1

Errors Related to Option Explicit

Option explicit can be a very good tool during the development of the scripts. It acts as a safeguard against accidental spelling mistakes while working with Variables or a strange error which can not be viewed in naked eyes.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 24
  • 28
  • 12
  • 23
  •  
  •  
  •  
  •  
  •  
  •  
    87
    Shares

80 COMMENTS

  1. What’s up, alwayѕ i used to check webpage posts here early in the morning, since i enjoy to learn more and more.

  2. Ꮋіya! I know this is kinda off topic but I’d figuгed I’d ask.

    Would you be interested in trading links or maybe ɡuеst writing
    a blog article or vice-versa? My site covers a lot of the
    same topics as yours and I think we could greatly benefit fгom each
    otһer. If you might be interested feel free tօ shoot me an email.
    I look forward to һeɑring from you! Ƭerrific blog by the way!

  3. Is primary goal of company earning huge returns?
    Your clients will for you to see the same internet website layout.
    Pick 10-20 publications of one’s topic region and change them in to a
    collection.

    • IsidraFitzmaurice95, Thank you. I am really not looking for huge profit as of right now. I just want to make the website reach in terms of knowledge sharing. However I will surely keep your comment in mind.

      Regards,
      Animesh

  4. I have been browsing online more than 4 hours today, yet I never found any
    interesting article like yours. It’s pretty worth enough for me.
    Personally, if all webmasters and bloggers made good content
    as you did, the web will be much more useful than ever before.
    Howdy! This blog post could not be written any
    better! Looking through this post reminds me of my previous roommate!
    He always kept talking about this. I’ll send this post to him.
    Fairly certain he’s going to have a very good read.

    Thanks for sharing! Howdy just wanted to give you a quick heads up.

    The text in your article seem to be running off the screen in Chrome.
    I’m not sure if this is a formatting issue or something
    to do with internet browser compatibility but I thought
    I’d post to let you know. The design and style look great though!
    Hope you get the problem solved soon. Kudos

  5. Wow! This blog looks exactly like my old one! It’s on a completely different topic but it has pretty
    much the same layout and design. Excellent choice of colors!
    Hello just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Opera.
    I’m not sure if this is a format issue or something to do with web browser
    compatibility but I figured I’d post to let you know.
    The style and design look great though! Hope you get the issue
    resolved soon. Thanks Woah! I’m really digging the template/theme of this site.

    It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance”
    between user friendliness and visual appearance.
    I must say you have done a fantastic job with this.
    In addition, the blog loads very quick for me on Opera.
    Superb Blog!

    • Hello Chrinstine,
      I have not checked in Opera till now. Now I got this as a requirement. Surely I will look into this issue. I will rectify if I can.I would suggest to look it at chrome and mozilla.
      Thanks your kind words. It means a lot for a budding blogger like me.

      Regards,
      Animesh

  6. It’s really a great and useful piece of information. I’m glad that you
    simply shared this helpful info with us. Please keep us informed
    like this. Thank you for sharing.

  7. I was curious if you ever thought of changing the layout of your site?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so
    people could connect with it better. Youve got an awful lot of text for only having 1 or 2 pictures.

    Maybe you could space it out better?

  8. Wonderful items from you, man. I’ve understand your stuff prior to and you’re simply too wonderful.
    I really like what you’ve acquired right here, really like
    what you are stating and the way in which during which you
    are saying it. You’re making it enjoyable and you continue to care for to stay it sensible.
    I cant wait to learn far more from you. That is actually a tremendous web
    site.

  9. Wоnderful article! This iѕ the kind of info that should be
    shared aroսnd the net. Shame on the sеek engines for not positioning this submit higher!
    Come on over and seek ɑdѵice from mʏ site .
    Ꭲһanks =)

  10. There has been a lot of fuss about SEO or search
    engine optimization. Some would say it would take months and even years to
    be one important the search engines even though some even claim it would certainly
    be just a matter of weeks for you to view results and dominate Google which
    is which?

    Link exchanging with other blogs in which in equivalent market as yours.
    You are unable to want any that price range direct competition with remember.
    This can help you out if these linked sites have a good page ranking in Google
    or other popular search engines.

    The success of your article really depends onto your headline (title).

    This just what the user sees . Make sure you grab their undivided attention so they will want to read
    your article. 75% of as well as effort writing your article often be spent on creating a title.

    Without a successful page, positive if you find it difficult to
    make quick money online. The landing page is come into making cash.

    Don’t give poor effort in completing this method. It is a substantial reason for the downfall many Internet marketing
    campaigns.

    You are afraid to be an expert on google marketing added with these techniques either.
    A person have know basic HTML, you’ll be able to can implement these goes.

    So maybe you should activate with just adding say Meta tags and seeing
    how that gets an outcome when copy and paste a associated with your
    pages text within a search locomotive. Then change the Meta tags to another thing and re-submit your
    pages to figure out. Next time you execute a search
    the new same keyword and key phrase as before, you will have a choice of could be getting
    you the best information.

    Email marketing or advertising. Some online users do don’t
    have much time to check your own everyday notice your
    latest offerings. Bring the content to them, right inside mailbox by
    sending them email advertising.

    For details on the best way to resize your Headline tags and correct use of hyperlinks using
    Dreamweaver booking out our article ‘Optimizing in Dreamweaver for Dummies’.

  11. It’s awesome to pay a quick visit this website and reading the views of all friends regarding this piece of writing, while I am also keen of getting familiarity.

  12. Simply want to say your article is as astonishing. The clearness in your submit is simply nice and that i can suppose you are a professional on this subject. Fine with your permission let me to seize your feed to keep updated with approaching post. Thanks one million and please continue the rewarding work.

  13. I’m extremely impressed with your writing skills as well as with
    the layout on your blog. Is this a paid theme or did you modify it yourself?
    Anyway keep up the nice quality writing, it is rare to see a great
    blog like this one today.

  14. Heya! I know this is somewhat off-topic but I had to
    ask. Does operating a well-established blog such as yours take a
    large amount of work? I am brand new to blogging but I do write in my
    journal daily. I’d like to start a blog so I can share my experience and feelings online.
    Please let me know if you have any kind of ideas or tips
    for brand new aspiring bloggers. Thankyou!

    • Hello friend,
      I do it as part of my learning. The sole objective of this blog is to read and find out the summary and then write it here for my future reference. Now interestingly, this is helping everybody. A kind of free learning. Coming back to your original question if you prepare your blog for money, it may take few months to see actual earnings as you will be focused to post all current topics where CPC will be high. But this is not directly linked to earn money. Hence the earning is in snail’s pace.

      Regards,
      Animesh

  15. Heya great website! Does running a blog such as this
    require a lot of work? I’ve very little understanding of computer programming but I was
    hoping to start my own blog soon. Anyhow, if you have any suggestions or techniques for new blog owners please share.
    I know this is off topic nevertheless I just had to ask.
    Thanks a lot!

    • Hello friend,
      I do it as part of my learning. The sole objective of this blog is to read and find out the summary and then write it here for my future reference. Now interestingly, this is helping everybody. A kind of free learning. Coming back to your original question if you prepare your blog for money, it may take few months to see actual earnings as you will be focused to post all current topics where CPC will be high. But this is not directly linked to earn money. Hence the earning is in snail’s pace.

      Regards,
      Animesh

  16. Way cool, some valid points! I appreciate you making this article available, the rest of the site is also high quality. Have a fun.

  17. Just desire to say your article is as surprising. The clearness on your submit is simply spectacular and that i could think you are knowledgeable on this subject.
    Well together with your permission let me to clutch your feed to stay updated with drawing close post.
    Thanks 1,000,000 and please keep up the enjoyable work.kristy jager

  18. Aw, this was an exceptionally nice post. Spending some time and actual effort to make a great article?
    but what can I say? I put things off a lot and never seem to get nearly anything
    done.jesuscruickshank

  19. Thank you for the auspicious writeup. It in fact was a amusement account
    it. Look advanced to far added agreeable from you!
    However, how could we communicate? clevelandshimizu

  20. Link exchange is nothing else but it is only placing the
    other person’s weblog link on your page at suitable place and other person will also do similar in support of you.charlottehowell

  21. Well I definitely liked reading it. This information offered by you is very practical for accurate planning.alvaromei

  22. Hi there, just became alert to your blog through Google,
    and found that it is really informative. I am
    going to watch out for brussels. I’ll appreciate if you continue this in future.
    Many people will be benefited from your writing. Cheers!

  23. A person essentially lend a hand to make severely articles I might
    state. This is the very first time I frequented your web page and thus
    far? I amazed with the research you made to make this particular publish amazing.

    Fantastic activity!

  24. Howdy! I could have sworn I’ve been to this site before but after looking at many of the articles I realized it’s new to me. Anyways, I’m definitely delighted I discovered it and I’ll be book-marking it and checking back frequently!

  25. Hey there would you mind stating which blog platform you’re working with?
    I’m looking to start my own blog in the near future
    but I’m having a tough time selecting between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design seems different
    then most blogs and I’m looking for something
    completely unique. P.S Apologies for getting off-topic but I had
    to ask!

  26. I’m impressed, I need to say. Actually not often do I encounter a weblog that’s each educative and entertaining, and let me tell you, you could have hit the nail on the head. Your thought is excellent; the problem is something that not enough persons are speaking intelligently about. I am very completely happy that I stumbled throughout this in my search for one thing relating to this.

  27. Amazing blog! Do you have any helpful hints for aspiring writers?
    I’m hoping to start my own site soon but I’m a little
    lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m totally overwhelmed ..

    Any suggestions? Appreciate it!

  28. My partner and I absolutely love your blog and find nearly all of your post’s to be what precisely I’m looking for. Do you offer guest writers to write content available for you? I wouldn’t mind producing a post or elaborating on many of the subjects you write about here. Again, awesome web site!

  29. I just like the helpful info you supply to your articles. I will bookmark your blog and take a look at again right here frequently. I am quite certain I’ll learn many new stuff right right here! Best of luck for the next!

  30. Whats up very nice web site!! Man .. Excellent .. Amazing .. I’ll bookmark your site and take the feeds also…I am glad to find numerous helpful info right here in the publish, we’d like develop extra techniques in this regard, thank you for sharing. . . . . .

  31. Its like you read my mind! You appear to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but other than that, this is great blog. A fantastic read. I’ll certainly be back.

  32. Its like you learn my thoughts! You appear to know a
    lot approximately this, like you wrote the e-book in it or something.
    I feel that you just can do with some p.c. to drive the
    message home a little bit, however instead of that, this is great blog.
    A great read. I’ll certainly be back.

  33. If you happen to significant fortunate people forms, referring by natural means, additionally you catch the attention of some sort of envy in consideration of those types the other campers surrounding you which have tough times about this subject. awnings

  34. Thanks a bunch for sharing this with all people you really know what you’re talking approximately!
    Bookmarked. Kindly also consult with my web site =). We
    will have a hyperlink trade contract among us

  35. Hi there! This is my first comment here so I just wanted to give a quick shout
    out and say I genuinely enjoy reading your articles. Can you suggest any other blogs/websites/forums that deal with
    the same subjects? Many thanks!

  36. I am extremely impressed with your writing skills as well as with the layout on your weblog.
    Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see
    a great blog like this one today.

  37. Hi there, just became alert to your blog through Google, and found that
    it is really informative. I’m going to watch out for brussels.
    I’ll appreciate if you continue this in future. Numerous people
    will be benefited from your writing. Cheers!

  38. This design is steller! You definitely know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  39. Woah! I’m really enjoying the template/theme of this website.

    It’s simple, yet effective. A lot of times it’s challenging to get that “perfect balance” between usability and visual appearance.
    I must say you’ve done a fantastic job with
    this. Additionally, the blog loads super fast for me on Safari.
    Exceptional Blog!

  40. I was suggested this web site by my cousin. I’m not sure
    whether this post is written by him as nobody else know such detailed about my trouble.
    You’re amazing! Thanks!

  41. Heya i’m for the first time here. I came across this
    board and I find It really useful & it helped me out much.

    I hope to offer something again and help others like you aided me.

  42. Good day! Do you use Twitter? I’d like to follow you if that would be ok.

    I’m absolutely enjoying your blog and look forward
    to new updates.

  43. Hey are using WordPress for your blog platform? I’m new
    to the blog world but I’m trying to get started and set up my own. Do you require any
    html coding knowledge to make your own blog? Any
    help would be really appreciated!

  44. Hello are using WordPress for your site platform?

    I’m new to the blog world but I’m trying
    to get started and create my own. Do you require any coding expertise
    to make your own blog? Any help would be really appreciated!

  45. It’s really a great and useful piece of information. I’m happy that you just shared this useful information with us. Please stay us up to date like this. Thank you for sharing.

  46. Hello there! I could have sworn I’ve been to this blog before but after
    checking through some of the post I realized it’s new to me.

    Anyways, I’m definitely happy I found it and I’ll be book-marking
    and checking back frequently!

LEAVE A REPLY

Please enter your comment!
Please enter your name here