Name
Execute Statement
Syntax
Execute statement
-
statement
Use: Required
Data Subtype: String expression
A string expression containing one or more statements for execution.
Description
Executes one or more statements.
Rules at a Glance
statement
is a string literal containing one or more statements to execute, or a string variable containing one or more executable statements. An executable statement is any call to a user-defined procedure or function, or any intrinsic VBScript command.You can put multiple statements in the expression; separate them with colons.
You can also separate the arguments with embedded line breaks. We prefer the colons, as it makes the code easier to read.
If
statement
includes an equal sign, it is interpreted as an assignment rather than an evaluation. For example, x = 3 assigns the value 3 to the variable x, rather than comparing the value of the variable x with 3.Code executed by the
Execute
statement inherits the scope of the routine from which it’s called; all variables visible to the calling routine are visible to it. The sole exception is code that creates a new procedure (as in the example). This new procedure does not inherit the scope of the calling routine; instead, only global variables and objects are visible to it. However, the procedure itself is not globally available throughout the script; it can be called only from the procedure in which it theExecute
statement was executed.
Example
The following is a corrected version of an example appearing in ...
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.