Mar 06
Here's a Visual Basic function I wrote called getDataType that returns a string representation of the passed item's data type. This is different from VarType in that VarType returns an integer, and this returns a human readable string. I know this is similar to the TypeName function but this is just my spin on it.
Download getDataType.bas (May 31, 2006)
MSDN Links
TypeName Function Reference
VarType Function Reference
Public Function getDataType(v As Variant) As String Select Case VarType(v) Case vbArray getDataType = "vbArray" Case vbBoolean getDataType = "vbBoolean" Case vbByte getDataType = "vbByte" Case vbCurrency getDataType = "vbCurrency" Case vbDataObject getDataType = "vbDataObject" Case vbDate getDataType = "vbDate" Case vbDecimal getDataType = "vbDecimal" Case vbDouble getDataType = "vbDouble" Case vbEmpty getDataType = "vbEmpty" Case vbError getDataType = "vbError" Case vbInteger getDataType = "vbInteger" Case vbLong getDataType = "vbLong" Case vbNull getDataType = "vbNull" Case vbObject getDataType = "vbObject" Case vbSingle getDataType = "vbSingle" Case vbString getDataType = "vbString" Case vbUserDefinedType getDataType = "vbUserDefinedType" Case vbVariant getDataType = "vbVariant" Case Else getDataType = "Unknown Data Type" End Select End Function