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

write a vb script to calculate factorial of a number?

5 Answers  


write a vb script to create a folder?

3 Answers  


What is the use of the instr function?

0 Answers  


Explain How do you create a recordset object in vbscript?

0 Answers  


what is the code in QTP to take screen shot? Please send me any one to my mail id. my mailid is manu.sanepalli@gmail.com

4 Answers   TCS,






Can anybody code this problem for me in VB script - Create an array of 4 elements, increase its size to 7 elements and then find out which of the elements are prime (use functions)

2 Answers  


What is the purpose of folders object of scripting.filesystemobject class in vbscript?

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,


What is the use of the formatdatetime function in the vbscript language?

0 Answers  


Create a file system object to do the following i. Create a folder ii. Create a text file in the folder iii. Update text file with some tex

2 Answers  


Can any 1 modify the code whr in want to add\rename a excel sheet in qtp?

1 Answers  


about vb scripting programs this type of all question& answers

0 Answers  


Categories