Answer Posted / jim c
Option Explicit forces the programmer to declare all
variables, rather than letting them be implicitly declared
upon their first use.
This enforces good programming practices and avoids
ambiguity of variable scope.
Here are some simple code examples:
'*************************************
i = 1
Call mySub
WScript.Echo i
Sub mySub
i = 10
End Sub
'*************************************
In this first example, because the programmer is relying on
implicit variable declaration, the subroutine is modifying
global variable i, and the printed result is 10. Now, modify
the code so that the variables are declared:
'*************************************
dim i
i = 1
Call mySub
WScript.Echo i
Sub mySub
dim i
i = 10
End Sub
'*************************************
Now, we actually have two different variables named i, one
with global scope, and one with local scope. The printed
result is now 1.
Since a lot of programmers use i in For..Next loops, you can
see how this could result in unpredictable results without
explicit variable declaration
Is This Answer Correct ? | 8 Yes | 3 No |
Post New Answer View All Answers
There are 5 web pages.write a script to click the button on 4th web page.
what is the object hyrarchy in QTP for a web based application
why variable name should not exceed 255 characters?
I need to get some data from data base and store this
(retrieved) data in a excel sheet using VB script in QTP9.0
I have created connection for data base
I have created as excels sheet by using
Set XL=CreateObject("Excel.Application")
XLworksheet.cells(1,1).value= rs.fields.item("<
How can you fetch the value of a cookie?
Explain about adodb.stream class?
i am having some basic knowledge in c and VB 6.0. i qtp i want to know how to write the codings. by recording it is generating lot of codings. for example i want to test the text box. senerio is text box should not accept alphabets if it accept alphabets we should return fail status if it get number we should return pass status. how to write coding in vb script please help me
Why is the use of exit do or exit for statements within loops discouraged?
Please let me Know regarding any material regarding VB Scripting which should be easily understandable for Beginners.
Explain sga memory structures?
Why is it recommended to close the database connection every time after the work is completed?
What are subprocedures in vbscript?
What are the different types of operators and their order of precedence?
Write a vbscript procedure that converts feet to inches. Hint: there are 12 inches in a foot?
How to Enter Values on the Command promt using VB script