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
Mention when to use function procedures and what are its characteristics?
When to use function procedures and what are its characteristics?
Explain about .wsf files?
where can i learn VB scripint ?
what do you mean .ota mobile format
Which command is used for writing text on a page?
wht must be the interview question on corinthian information technology solutions incorporated.
How are values assigned to the variables in the vbscript language?
What is select case statement?
Please let me Know regarding any material regarding VB Scripting which should be easily understandable for Beginners.
How will you convert a string to upper case string using vbscript?
How can you fetch the value of a cookie?
Is VB Script Case sensitive or Case insensitive?
Explain about the functionality of vb script?
how to acces the remote mechine using vb cript(QTP)