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

How to return only alpha bate string from an string str = "bibhu@#$%&das&*)(SUndar"

4 Answers   Cap Gemini,


How to scroll down a page while recording in qtp. suggest me any method apart from low level recording.

0 Answers  


How to Import data from a file (file is on the desktop) to the data table

2 Answers   IBM,


How to create a function in vbscript?

0 Answers  


I have attended Anovatek Software QTP interview. They will give us computer and one web based application with QTP. We have to automate some records (already updated records or new records) using QTP Data driven testing. But we should use for loop? Can any one know how to do data driven testing using For loop?

0 Answers  


How to open excel in vb script?

0 Answers  


What is vbscript?

0 Answers  


how to write validation function for date in vb script

0 Answers  


How many data types are supported in Vbscript?

3 Answers   Microsoft,


Which in-built function is used to format the number in the vbscript language?

0 Answers  


Does VB/Win make standalone .EXE files?

0 Answers  


hey please tell me how to retriev data from excel sheet which puts the login name and password in the application? plz send me the code..please help me

6 Answers   HP,


Categories