Name
Execute Statement
Syntax
Execute statementstatementUse: Required
Data Type: String expression
A string expression containing one or more statements for execution.
Description
Executes one or more statements.
Rules at a Glance
statementmust evaluate to a string that contains 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.
If
statementincludes an equal sign, it is interpreted as an assignment rather than an evaluation. For example,x = 3assigns the value 3 to the variable x, rather than comparing the value of the variable x with 3.In VBScript, a program fragment such as
x=3can be interpreted as both an assignment statement (assigning the value 3 to the variable x) or as a comparison expression (for exampleIf x = 3 Then...) TheExecuteandExecuteGlobalstatements always treat strings of the forma = bas assignment statements. Use Eval to interpret strings of this form as expressions.
Example
The following is a corrected version of an example appearing
in online help that appears to do nothing. In this case, the
Execute statement is used to
execute a procedure named Proc2, and the entire source code for the
procedure is also stored to the string S
that is passed to the Execute
statement:
dim S S = "Proc2 : " S = S & "Sub Proc2 : " S = S & "Dim x : " ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access