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
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 |
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 |
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 |
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 |
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 |
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 |
give me the code for check point for validating application
What is difference between function and procedure?
41 Answers HCL, IBM, iGate, Infosys, TCS, Veritas, Wipro,
Hi, I Install QTP 9.2 in windows Vista. but it is not supporting IE. it is supporting only windows based application. could I change any setting in Vista for supporting IE.. ?? thanks in advance...
Did QTP prove efficient for your project? Yes or No, explain?
What is the extention of Virtualobject
how to identify an object which is not in the object repository identification can be done using descriptive programming.
Hi, I'm a beginner in QTP and planning of a certification in QTP, but have no idea about it :P. Could anyone please tell me what certifications that a QTP- beginner can take? What is the fees and the syllabus for the certification? Please reply soon. Thanks Vidhya
Once we get the Test Result from QTP.,I Have to convert into Excel file format..Is it possible..Can any gudie me regarding this... For Example : Total Test Case is : XXXXX Test Case passed : XXX Test Case Failed : XXX -------- Total XXXXXX ---------
How many types of trigger events are there in qtp?
when a test case is written how u test using qtp
ACTUALLY I AM WORKING IN THE DISTRIBUTION DOMAIN.MY COMPANY IS PROVIDING DISTRIBUTION SOFTWARE FOR PHARMA AND FMCG DISTRIBUTORS.HERE I AM USING QTP 9.2.HERE IN MY APPLICATION WHILE RECORDING ONE WINDOW APPEARS.IN THAT I CAN SELECT THE ITEM OR NO NEED TO SELECT.BUT WHILE RUNNING THE SAME SCRIPT THE WINDOW MAY NOT APPEAR OR APPEAR.HOW TO WRITE SCRIPT FOR THIS
If there are 100 checkboes in a page then how can we select all chexkboxes at once through descriptive programing in QTP using vb script. Please send the answers...