Eval Function

Syntax

Eval(Expr[, Depth])

Group

Miscellaneous

Description

Returns the value of the string expression as evaluated.

Parameters

Parameters Description
Expr Evaluates the string value.
Depth Indicates how deep into the stack to locate the local variables. If Depth = 0, use the current procedure. If this value is omitted, the depth is 0.

See also

Assign


Sub Main
    Dim X As String
    X = "Hello"
    Debug.Print Eval("X") 'Hello
    A
End SubSub A
    Dim X As String
    X = "Bye"
    Debug.Print Eval("X") 'Bye
    Debug.Print Eval("X",1) 'Hello
End Sub