What's the best way to iterate over an array in a variant?

How do I iterate over arrays that are passed in a Variant variable? The only way I can up with is to first convert the array into an array of variants. Something like this:

Function Convert(theArray as Variant) As Variant()
   dim result() as Variant

   Select Case theArray.ArrayElementType
   Case Variant.TypeBoolean
      dim bools() as Boolean = theArray
      for each b as Boolean in bools
      next b
   Case Variant.TypeInteger
      dim ints() as Integer = theArray
      for each i as Integer in ints
      next i
   Case ...
   End Select

   return result
End Function

Isn’t there a better way to do this? I’m using Xojo 2017r1.1.

I have never found a better way than what you describe here. It’s a real pain in the buttocks.