Method: Execute for VBS
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: Execute for VBS
Method: Execute for VBS
Executes instructions. If you use an instruction like "x = y", the Execute method assigns the y value to the x variable. If, instead, you want to check whether both values are the same, use the Eval method.
Object.Execute(string)
| Object | VBS Object with this method. You do not need to specify this object. |
| string | Variant Specifies a string containing one or more instructions. |
The following example illustrates how to use the Execute method:
Dim MyVar1, MyVar2 MyVar1 = 1 MyVar2 = 2 Call Execute("MyVar1 = MyVar2 + 1") Call MsgBox(MyVar1) ' Returns 3
The following example defines a HelloWorld procedure and executes it:
Dim MyStr MyStr = "Sub HelloWorld() : Call MsgBox(""Hello World!"") : End Sub" Call ExecuteGlobal(MyStr) Call HelloWorld