Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone

Registered : 108,415

HOME > VBScript Manual > Execute Statement

Microsoft® Visual Basic® Scripting Edition
Execute Statement
 Language Reference 
Version 5 

See Also

Executes one or more specified statements.
Execute statement

The required statement argument is a string expression containing one or more statements for execution.  Include multiple statements in the statement argument, using colons or embedded line breaks to separate them.

In VBScript, x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. If they do, result is True; if they are not, result is False. The Execute statement always uses the first interpretation, whereas the Eval method always uses the second.

Note  In Microsoft® JScript, no confusion exists between assignment and comparison, because the assignment operator (=) is different from the comparison operator(==).

The context in which the Execute statement is invoked determines what objects and variables are available to the code being run. In-scope objects and variables are available to code running in an Execute statement. However, it is important to understand that if you execute code that creates a procedure, that procedure does not inherit the scope of the procedure in which it occurred.

Like any procedure, the new procedure's scope is global, and it inherits everything in the global scope. Unlike any other procedure, its context is not global scope, so it can only be executed in the context of the procedure where the Execute statement occurred. However, if the same Execute statement is invoked outside of a procedure (i.e., in global scope), not only does it inherit everything in global scope, but it can also be called from anywhere, since its context is global. The following example illustrates this behavior:

Dim X			' Declare X in global scope.
X = "Global"		' Assign global X a value.
Sub Proc1	' Declare procedure.
  Dim X		' Declare X in local scope.
  X = "Local"	' Assign local X a value.
			' The Execute statement here creates a
			' procedure that, when invoked, prints X.
			' It print the global X because Proc2
			' inherits everything in global scope.
  Execute "Sub Proc2: Print X: End Sub"
  Print Eval("X")	' Print local X.
  Proc2		' Invoke Proc2 in Proc1's scope.
End Sub
Proc2			' This line causes an error since 
			' Proc2 is unavailable outside Proc1.
Proc1			' Invoke Proc1.
  Execute "Sub Proc2: Print X: End Sub"
Proc2			' This invocation succeeds because Proc2
			' is now available globally.
The following example shows how the Execute statement can be rewritten so you don't have to enclose the entire procedure in the quotation marks:

S = "Sub Proc2" & vbCrLf
S = S & "  Print X" & vbCrLf 
S = S & "End Sub"
Execute S

ThaiCreate.Com Forum

Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO

สุดยอด Source Code V2.0


Hit Link

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2020 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่