title: Is there a way of checking if parameter can iterated over
body: <p>I would like to know if there is a way of knowing if parameter can be iterated over using <code>For Each</code> loop before using it.</p>
  
  <h3>Method AddRange</h3>
  
  <p>This method can accept various data types. Ideally, user would pass an container which contains 0 or more items.</p>
  
  <pre class="lang-vb prettyprint-override"><code>' Class name - Employees
  Private pItems As New Collection
  Public Sub AddRange(ByVal Items As Variant)
  
      ' Here should be logic of detecting if Items can be iterated over.
      ' If Items is not a container, throw an error.
      ' Otherwise, proceed with adding items.
  
      Dim Item As Variant
      For Each Item In Items
          pItems.Add Item
      Next Item
  
  End Sub
  </code></pre>
  
  <h3>Client code</h3>
  
  <pre class="lang-vb prettyprint-override"><code>Public Sub Start()
  
      Dim Emps As New Employees
      Dim Department As New Collection 'of Employees
      Emps.AddRange Department
  
      Dim AnotherDepartment(0) As Variant 'of Employees
      Emps.AddRange AnotherDepartment
  
      Dim NewJoiners As New Employees
      Emps.AddRange NewJoiners
  
      ' This should not work.
      Dim EmployeeName As String
      Emps.AddRange EmployeeName
  
  End Sub
  </code></pre>