<-- Previous || Up || Next -->

Variant Of Type Function
Convert Values Class

Public Function VariantOfType( _
    ByVal vVarType As Variant _
    ) As Variant

Return a value of the specified data type.

Examples:
    IsNull(VariantOfType(vbNull)) = True
    IsEmpty(VariantOfType(vbEmpty)) = True
    VariantOfType(vbInteger) = 0%
    VarType(VariantOfType(vbInteger)) = vbInteger
    VariantOfType(vbSingle) = 0!
    VarType(VariantOfType(vbSingle)) = vbSingle
    VariantOfType(vbString) = ""
    VarType(VariantOfType(vbString + vbArray)) = vbString + vbArray
See also:
    FixUpToType Function
    FixUps Class
vVarType: The data type identifier as specified by one of the vb Constants like vbInteger, vbString, vbNull, etc. The data type identifier can be modified with the addition of vbArray. Function returns Null if vVarType is Null or cannot be fixed up to a number.

Function returns Null if vVarType is (vbNull,) vbArray, vbVariant, or if it does match one of the known data type identifiers. If vVarType represents a numeric data type, the function returns the value 0 (zero) using the specified data type. If vVarType represents an object pointer, the function sets its result to Nothing. Function returns an empty string if vVarType is vbString.

v1.2 BugFix: Extended this function to generate arrays of any data type (with the exceptions noted below).
v1.5 Change: This function has been extended to support the new Decimal data type in VB 6.0, except that it cannot generate an array of Decimal values.

vbDataObject + vbArray: When vVarType is vbDataObject + vbArray, this function returns an array of type vbObject.

vbEmpty + vbArray: When vVarType is vbEmpty + vbArray, this function returns an array of type vbVariant with the single array element Empty (VarType = vbEmpty).

vbError + vbArray: When vVarType is vbError + vbArray, this function returns an array of type vbVariant with the single array element set to Error 0 (VarType = vbError).

vbNull + vbArray: When vVarType is vbNull + vbArray, this function returns an array of type vbVariant with the single array element set to Null (VarType = vbNull).

vbDataObject: When vVarType is vbDataObject, this function returns a value ("Nothing") of type vbObject.

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.