TypeName

Public Function TypeName(ByVal Expression As Variant) As String

Returns the name of the type of the specified expression.

For object-variables, the name of the object-class is returned (for example 'Recordset' or 'clsString')

Public Function IsStandardNumber(pParameter As Variant) As Boolean
   Return TypeName(pParameter) In {"Long", "Double"}
End Function

Public Function SetValueInContainer(pContainer As Variant, pElementName As String, pNewValue As Variant) As Boolean
   Select Case TypeName(pContainer)
   Case "Collection"
       pContainer.TryRemove(pElementName)
       pContainer.Add pNewValue, pElementName
   Case "Dictionary"
       pContainer(pElementName) = pNewValue
   Case "Recordset"
       Try
           pContainer.Fields(pElementName).Value = pNewValue
       Catch
           Return False
       End Try
   Case Else
       Return False
   End Select
   
   Return True
End Function

See also: