When and why do you use "OPTION EXPLICIT" in VB Script.
Is there any online help or something to learn the script
for Beginners?

Answer Posted / pallavi nandula

When you use the Option Explicit statement, you must
explicitly declare all variables using the Dim, Private,
Public, or ReDim statements. If you attempt to use an
undeclared variable name, an error occurs.

VBScript ingeneral doesn't need variable declaration. For
example without using "Dim" a variable can be directly used
for assigning etc. For ex: temp=1

However, such practise can always be error prone. Ex: if i
want to use the same variable in someother statement and
miss spell it,say

tempe=temp+1

VBScript still considers "tempe" as valid. This case if we
use OPTION EXPLICIT On top of our application and proceed
then application will not proceed unless until u declare
each and every variable. Hence u make sure that ur variable
is serving ur purpose.

in this example u recognize that "tempe" is not desired.
Hope this clarifies.

Is This Answer Correct ?    88 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

There are 10 rows in the datatable. How can we fetch 2 rows and then skip 3rd row. After that, pick 4th & 5th row and skip 6th row. Please share code

1203


How to use checkpoints in qtp ?

576


Explain the use of action split in qtp?

553


how to evalute defects in QTP script?

1480


What is the pros and cons between QTP and Rational Robot

3276






Explain different type of event trigger option.

533


How is test case write?

569


Hi All , How can we decicde for pariticular frame(DataDriven or Keword Driven)in Project? Thanks Balaji

1368


How software tester can use constants and variables in scripts?

1681


How is recording done when a application is over lapping the QTP application it gives a message object not recorded

1563


Is it possible to call from one action to another action in qtp?

552


i need qtp tutorial. pls send it to sridhar.k151@g mail.com

1630


what is the diffrence bw qtp architectute and qtp framework?

1533


In QTP can we feed the out of one browser(internet explorer) as an input to the another browser(mozilla firefox)? If yes explain how to do it with an example.

1521


How to record application running on the Virtual machine?

634