VBEval


 

VBEval>Function([parms]),result

 

Not supported in Macro Scheduler Lite.

 

Evaluates a VBScript expression, or function in the proceeding VBScript code block.  Parameters can be passed to the function.  The result of the function or expression is stored in the result variable which is a regular Macro Scheduler variable.

 

This command sometimes causes confusion.  As it is evaluating a VBScript expression the syntax used in the first part of the command - the VBScript expression - should be valid VBScript syntax.  To pass Macro Scheduler variables, embed them with the % symbol.  If passing a Macro Scheduler variable as a string, remember that VBScript expects strings with quote marks around them.  See examples below.

 

Note that since VBEval evaluates any valid VBScript expression it can do more than just execute VBScript functions.  E.g. It could be used to return the value of a VBScript variable, or any other expression, such as a mathematical calculation.

 

It is possible to set the VBScript code timeout using the VBS_TIMEOUT variable.  By default VBScript code will never timeout.  To set a timeout, set VBS_TIMEOUT to a value in milliseconds.

 

Abbreviation : VBE

See also: VBRun

Links to VBScript Documentation: http://www.mjtnet.com/resources.htm

 

Example

 

VBSTART

 

Function MultiplyNums (d,a)

  MultiplyNums = d * a

End Function

 

Sub DisplayMessage (msg)

  MsgBox msg

End Sub

 

Function GetName

  GetName = InputBox("Enter Your Name : ")

End Function

 

Function PointlessStringExample(somestring)

  DisplayMessage(somestring)

  StringExample = somestring

End Function

 

VBEND

 

Let>a=5

VBEval>MultiplyNums(%a%,2),answer

MessageModal>answer

 

VBRun>DisplayMessage,Hello World

 

VBEval>GetName,name

MessageModal>Your Name is : %name%

 

Let>text=Hello World

VBEval>PointlessStringExample("%text%"),sametext

 

//Evaluate built in VBScript code,

//no code in VBSTART/VBEND block required
 VBEval>Timer,elapsed
 VBEval>MsgBox(%elapsed%),nul