Eval - VBScript
Overview
Eval evaluates an expression as a VB Script code and returns the result. It allows dynamic execution of VB Script code at runtime.
Syntax
Eval(expression)
Parameters:
- expression: A string representing the VB Script code to be evaluated.
Options/Flags
None
Examples
Simple Usage:
Dim result = Eval("2 + 3")
Complex Usage:
Dim code = "If Len(str) > 10 Then str = Left(str, 10)"
Dim result = Eval(code, str)
Common Issues
- Ensure the expression is valid VB Script code.
- Use caution when evaluating expressions that may cause side effects (e.g., modifying global variables).
Integration
With Other VB Script Commands:
- Execute: Combines with Execute to run a longer code block as a script.
- CreateObject: Creates an object based on the evaluated expression.
Related Commands
- Execute
- CreateObject
- VBScript Help