It’s QUIZ time guys. This question comes from one of our fellow bloggers.
What is the difference between the two little snippets of codes given below?
AND
Can you find a problem with the 1st piece of code?
If yes,
- What is the problem?
- What is your solution to it?
Note:Â Please post your solution in the comments section below. I will publish the comments only after 24 hrs to give everyone a fair chance of attempting this quiz.
Update: Comments section is now open and answers from our blog readers can be seen below. Here is my explanation on differences between boolean, string and numeric comparison. This question was first asked by MaryAnne.
Equals to operator (=) compares string or numeric expressions. What is returned by Browser(”Browser”).Page(”Page”).Link(”Link).Exist(0) is boolean, as can be checked from
msgbox Typename(Browser(”Browser”).Page(”Page”).Link(”Link).Exist(0))
When a boolean expression (on the LHS) see an equal to operator, it must be implicitly getting changed into string or numeric expression depending on whether string or numeral is present on the other side(RHS).
So in 1st case both of these should work…
String comparison (String – “True” – is present. Note the quotes):
Numeric Comparison (Numeral -1- is present):
If you want to compare Boolean expressions on both sides use AND
Post from: Learn QTP
Quiz: Find the difference between these VBScript codes?
Related posts:
- HP QTP Quiz: Passing by value vs Passing by reference
- Quiz: A message box that will close automatically


Tweet This Post