Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

Answers were Sorted based on User's Feedback



When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / 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

When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / minni

On the top of the QTP script if u write Option Explicit
that means u r going to define every variable u r going to
define every variable u r using in the script as DIM.
for an example if u want to define an array ......
Option Explicit
Dim A(10)

Is This Answer Correct ?    26 Yes 12 No

When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / ritesh mahendrakar

You can declare variables with the Dim, Public or the
Private statement. Like this:

Dim myname
myname = "ritesh"

However, this method is not a good practice, because you
can misspell the variable name later in your script, and
that can cause strange results when your script is running.

If you misspell for example the "myname" variable
to "mynime", the script will automatically create a new
variable called "mynime". To prevent your script from doing
this, you can use the 'Option Explicit' statement. This
statement forces you to declare all your variables with the
dim, public or private statement.

Put the Option Explicit statement on the top of your
script. Like this:

Option Explicit
Dim myname
myname = "ritesh"

Is This Answer Correct ?    16 Yes 2 No

When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / shilpi

Use Option Explicit to avoid incorrectly typing the name of
an existing variable or to avoid confusion in code where the
scope of the variable is not clear.

when you use 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.

Is This Answer Correct ?    10 Yes 5 No

When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / vaibhav patil

You can also force the explicit declaration of variables by setting the keyword OPTION EXPLICIT . The <%OPTION EXPLICIT%> statement must appear before VBScript command,otherwise it will be treated as an invalid statement and generate error.

For eg,
<%Language=VBScript%>
<%OPTION EXPLICIT%>

Is This Answer Correct ?    1 Yes 0 No

When and why do you use "OPTION EXPLICIT" in VB Script. Is there any online help or somet..

Answer / siva

Hi:
Pallavi, Thank you very much for the elobarate answer.
I got the thing...

Can you also tell me the exact difference between
GUI and UI.

Thank you
Siva..........

Is This Answer Correct ?    3 Yes 6 No

Post New Answer



More QTP Interview Questions

1. Which function is used to check whether the specified object property achieves the specified value within the specified timeout below anyone is correct 1. Check Property 2. getToproperty 3. output Pls anybody can give the answer.. Thanks in advance...

1 Answers   Navis,


I want to learn QTP Online, where can I get quality training?

15 Answers   CSC,


how to write xml output check point bu useing descriptive programing .means without useing output check point

0 Answers  


How you automate testscripts one by one or modukewise or all at once

1 Answers   Diebold,


By default Action1 runs first in QTP. Is it possible to start the run with Action2?

9 Answers   Virtusa,






Diff b/w Health care domain and Banking Domain?

0 Answers  


Waht is User interface and Integration Testing?

1 Answers  


How to creating an output value using quicktest professional?

0 Answers  


I have 5 no.of Action in my Test. Out off which i should make 3rd action as my start-up action. How should i make it?

5 Answers  


How u perform exception handling in QTp,what is other name for ths?

2 Answers  


if devloper change only button names in present build then script will execute or not , why? Only gui changed.......

2 Answers   Cap Gemini,


In My application, having Copmany Name : Text Box and click Save button. if i enter a vlue, after run..........it shows the already exists. so how to enter random ro mmultiple names names into webedit box(company Name). without using DATATABLE THanks Ramesh

4 Answers   TCS,






Categories