how do you make the variable declaration mandatory?what is the use of "option explicit"?

Answers were Sorted based on User's Feedback



how do you make the variable declaration mandatory?what is the use of "option explicit"?..

Answer / cnu_thatavarthi

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

how do you make the variable declaration mandatory?what is the use of "option explicit"?..

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

Post New Answer

More VB Script Interview Questions

What are the rules to name variable in vbscript?

0 Answers  


How strcomp function works?

0 Answers  


a;;b;c;;;d in this string output is abcd will come how can we do that in vbscript in QTP testing?

2 Answers  


What are the 2 ways in which a variable can be declared in the vbscript language?

0 Answers  


Explain about operator precedence in vb script?

0 Answers  






How to delete a cookie using vbscript?

0 Answers  


Which object is used to work with the database in the vbscript language and what statement is used to create this object?

0 Answers  


what is extension of the file if its saved from recovery manger to some drive

1 Answers  


Explain about the support of asp for vb script functionality?

0 Answers  


How can you fetch the value of a cookie?

0 Answers  


Explain about tristate constants?

0 Answers  


how to write a vb script in QTP for yahoo registration form, i want to check the performance also like performance test, stress, load test like that.

0 Answers  


Categories