Function Convert Values Class

VariantToVBEvalExpression

"Variant To Visual Basic Eval Expression" Return the string representation of any type of value as it would appear within a Visual Basic (non-Const) expression. Converts the value of a variant into a string that can be passed to the Eval function (in Access and Excel only).

Signature (Visual Basic / VBA)

Public Function VariantToVBEvalExpression( _
    ByVal vValue As Variant _
    ) As String

Code Example

    VariantToVBEvalExpression(False) = "False"
    VariantToVBEvalExpression(CInt(2)) = "2%"
    VariantToVBEvalExpression(CSng(2)) = "2!"
    VariantToVBEvalExpression(CByte(2)) = "CByte(2)" ' #4
    VariantToVBEvalExpression(#4/5/96#) = "#4/5/96#"
    VariantToVBEvalExpression("Word") = """Word"""
    VariantToVBEvalExpression(Null) = "Null"

Parameters

Parameter Description
vValue The value which is to be converted to its representation within Visual Basic expressions. Function generates an error when passed things like object pointers which have no string representation.

Notes & Version History

Note Bytes represented with the CByte() function as in example #4.
v1.5 Change This function has been extended to support the new Decimal data type in VB 6.0,