how do you make the variable declaration mandatory?what is the use of "option explicit"?
Answers were Sorted based on User's Feedback
Option Explicit
Dim strValue, strValue
strValue = 20
'Expected Error: Name(Variable) is redefined
Dim intA, intB
intC= intA+intB
'Expected Error: Name(Variable is undefined)
Note: If we can use Option Explicit we have To pass the all the variables And it Is indentify undefined And redefined
variables
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sonali
Option explicit will make compulsory to define each variable in the script .
if at the top of the script we have written "Option Explicit" and in Dim only two variables assigned but in script somewhere used 3rd and 4th variable also .
then it will display an error message stating that "Variable is Undefined " .
It will be very very usefull in lenghy scripts where we will use different Functions and then call functions .
| Is This Answer Correct ? | 0 Yes | 0 No |
How can we return a value from User Defined Function ? For Eg. we have 2 functions. In Fun1 i am getting 2 values (a,b) and i am addding those 2 and storing in to another var (c). Now i want to pass that var(c) to another function (fun2). What will be the script?
what is the standards used for writing the script in QTP
a function that takes an integer array as an argument and returns the largest value in the array. Use the function in a program
How can constants be declared in the vbscript language?
Explain How do you create a recordset object in vbscript?
Explain the tristate constants in vbscript?
Differentiate javascript and vbscript?
How strcomp function works?
How will you convert a string to upper case string using vbscript?
reverse the string without using reverse string?
What are lbound and ubound in the vbscript language?
In qtp, how to use XML files for framework. if the XML files are more Efficient than Excel files?