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 is the purpose of the Reporter.ReportEvent in QTP and also please give the brief description about Reporter.ReportEvent ?

4 Answers   CybAge,


write a vbscript for traffic signal

1 Answers  


How will you get the octal value of the given number in vbscript?

0 Answers  


Can someone please tell me what poor design in a relational database (not the layout or style) is and how it can be avoided? PLEASE...im desperate.

0 Answers  


What is Querystring collection?

0 Answers  






How to Convert Hex color code to color name in VB Script?

0 Answers  


We have 1 web page with names column. I am giving the Service Providers1,2,3.... @ that time dynamically some no of names are displaying in the webpage and The Pop up windows are opening(No.of Pop Up windows=No.of Names). The names may be diffar for each and every Service Provders (Dynamically) How can we handle the Dynamic values?

0 Answers  


how to write basic programs in VB Script like addition, multiplication?

14 Answers  


How are arrays declared in the vbscript language?

0 Answers  


How to write Descriptive programming in .VBS file i wrote this code but it is giving error.. Dim qtApp set qtApp=createobject("QuickTest.Application") qtApp.Launch qtApp.Visible=True Set objIE = CreateObject("InternetExplorer.Application") objIE.visible = True objIE.Navigate "www.gmail.com" browser("title:=gmail").title("title:=gmail")

2 Answers  


about vb scripting programs this type of all question& answers

0 Answers  


Could Anybody Please tell me What is the script for Find 3rd Largest element in the Array without using a SORT function int Find(int arr[], int size); Thanks in Advance..

0 Answers   Amazon,


Categories