Eval, Execute, and ExecuteGlobal

These three new VBScript functions are included in version 5 to create compatibility with the JavaScript Eval method. They each do about the same thing, but which one you use depend on the scope of what it is you're trying to to do. The idea is to provide a way to evaluate and execute code 'on the fly' at runtime. For instance, your user could type in x = (2+2) * 4, which you could then send to the Eval function. Eval would tell you that this formula results in the number 16.

Execute and ExecuteGlobal are for executing blocks of script code on the fly, whereas Eval is for executing single expression such as the example I just used. Deciding whether to use Execute or ExecuteGlobal depends on the name space that the script code you're executing needs to have access to, but I'm not going to get into that here.

First
Next