Ever wondering what datatype the various functions of VB6 actually return so that you could use appropriate one yourself? Wonder no more, use Explain!

VB Code:
  1. Option Explicit
  2.  
  3. Private Sub Explain(ByVal VarTypeValue As Long)
  4.     Dim strArray As String
  5.     If (VarTypeValue And vbArray) <> 0 Then strArray = " array"
  6.     VarTypeValue = VarTypeValue And Not vbArray
  7.     Select Case VarTypeValue
  8.         Case vbBoolean
  9.             MsgBox "Boolean" & strArray
  10.         Case vbByte
  11.             MsgBox "Byte" & strArray
  12.         Case vbCurrency
  13.             MsgBox "Currency" & strArray
  14.         Case vbDataObject
  15.             MsgBox "DataObject" & strArray
  16.         Case vbDate
  17.             MsgBox "Date" & strArray
  18.         Case vbDecimal
  19.             MsgBox "Variant Decimal" & strArray
  20.         Case vbDouble
  21.             MsgBox "Double" & strArray
  22.         Case vbEmpty
  23.             MsgBox "Variant Empty" & strArray
  24.         Case vbError
  25.             MsgBox "Variant Error" & strArray
  26.         Case vbInteger
  27.             MsgBox "Integer" & strArray
  28.         Case vbLong
  29.             MsgBox "Long" & strArray
  30.         Case vbNull
  31.             MsgBox "Variant Null" & strArray
  32.         Case vbObject
  33.             MsgBox "Object" & strArray
  34.         Case vbSingle
  35.             MsgBox "Single" & strArray
  36.         Case vbString
  37.             MsgBox "String" & strArray
  38.         Case vbUserDefinedType
  39.             MsgBox "User Defined Type" & strArray
  40.         Case vbVariant
  41.             MsgBox "Variant" & strArray
  42.     End Select
  43. End Sub
  44. Private Sub Form_Load()
  45.     Explain VarType(Timer)
  46. End Sub
Please note that this isn't 100% perfect, because VarType takes in Variant datatype and looks up which datatype the Variant holds the information in. For example, Mid and Mid$ both tell the variable type would be String, although Mid returns a String contained in a Variant whereas Mid$ returns just a String.

Yet this is helpful for figuring out to which type of variable datatype you should store the return value into for optimal memory and resource management.