CVar Function

Named Arguments

No

Syntax

CVar(expression)

expression

Use: Required

Data Type: Numeric or String

Same range as Double for numerics. Same range as String for non-numerics.

Return Value

expression cast as a Variant.

Description

Returns expression as a Variant data type; the data subtype is automatically selected by the CVar routine.

Rules at a Glance

There really aren't any rules: you can literally throw anything at CVar, and a variant of the appropriate data subtype is returned.

Programming Tips and Gotchas

Use CVar only in situations where you are confident that the data type you pass into the function isn't ambiguous; in other words, where you can be sure of the data subtype that CVar selects. If you need data of a particular data type, use the appropriate conversion function.

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.