Public Function FixUpToType( _ ByVal vValue As Variant _ , ByVal vVarType As Variant _ ) As Variant
VarType(2) = vbInteger FixUpToType(2, vbLong) = 2 VarType(FixUpToType(2, vbLong)) = vbLong FixUpToType("234", vbLong) = 234See also:
PromoteToMostCapableDataType Function FixUpVariantToBooleanMandSub Subroutine FixUpVariantToByteMandFn Function FixUpVariantToCurrencyMandSub Subroutine FixUpVariantToDateMandFn Function FixUpVariantToDecimalMandSub Function FixUpVariantToDoubleMandSub Subroutine FixUpVariantToIntegerMandSub Subroutine FixUpVariantToLongMandSub Subroutine FixUpVariantToSingleMandSub Subroutine FixUpVariantToStringFn FunctionvValue: The value whose data type is to be changed within the return value.
This function uses complicated rules (as described below) to determine how to change the data type of the value.
String: Function will return an empty string if vVarType is vbString and vValue is Null. Function will convert numeric vValue values to strings. Function will return string vValue values unchanged.
Boolean: If vVarType is vbBoolean and vValue is a number, numeric string, date, and date string, vValue is converted to Boolean. Otherwise, if vVarType is Boolean, the function returns False.
Numeric: If vVarType is one of the numeric data types (like vbByte, vbInteger, vbDouble, etc.) and vValue is a number, numeric string, date, and date string, then vValue is converted to the specified data type. If vValue is not within the range of values that the data type vVarType can represent, then the function will generate an error. Otherwise, the function will return the value 0 (zero) within a Variant of type vVarType.
DataObject: Function will always return the object pointer Nothing if vVarType is vbDataObject or vbObject.
Empty: Function will always return an Empty Variant if vVarType is vbEmpty.
Error: Function supports vVarType values of vbError with numeric vValue values.
Null: Function will always return Null if vVarType is vbNull.
Object: Function will always return the object pointer Nothing if vVarType is vbObject or vbDataObject.
Function will return Null if vVarType does not represent one of the known Visual Basic data types.
v1.5 Change: This function has been extended to support the new Decimal data type in VB 6.0,
Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.