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
What are the uses of vb script?
Which date function is used in the vbscript language to find the difference between the 2 dates?
Explain about vb script?
what is used of Property........End Property loop ? how to write the script for it?
What's the difference between vbscript and vb.net?
Which function is used in the vbscript language to convert the specified expression into a date type value?
If a calulator having 3 buttons (of any number)in 3 of them one is not working properly due to which answer is wrong always. write a script to find out which button is not working properly ?
create a form to accept username and password validate the username and password with using message box, display the corresponding user message
What is the use of the formatdatetime function in the vbscript language?
Can we create Crystal Report object in QTP?If yes then what it is and what are its various properties?
1) How can we use VB script in testing the application? 2) What all are the things(Software application to be installed in PC) we need to learn VBscript?
What are class properties?
What is the difference between a dictionary and an array?
when we use filter funtiom invb script(QTP)
Write a Program to add 2 numbers without using operators (+,-) and without using third variable. Note: Use VBScript only Hint: You can use other operators like '/' & '*'(Division & Multiplication)