IncludesType
Description
The IncludesType() method determines whether the array includes a certain type among its entries, returning True or False as appropriate.
Note
A list of data types supported in VBA is available in the official language documentation here.
Syntax
expression.IncludesType(SearchTypeName, [FromIndex])
Parameters
- Name
SearchTypeName- Type
String- Necessity
- Required
- Description
- The type name to search for.
- Name
FromIndex- Type
Long- Necessity
- Optional
- Description
- The position in this array at which to begin searching for
SearchTypeName; the first character to be searched is found atFromIndexfor positive values ofFromIndex, or at the array’sLengthproperty +FromIndexfor negative values ofFromIndex(using the absolute value ofFromIndexas the number of characters from the end of the array at which to start the search). Defaults to the array’sLowerBoundproperty.
- Name
recurse- Type
Boolean- Necessity
- Optional
- Description
- If the array is jagged (an array of arrays) or multidimensional (which are stored internally as jagged arays) and you wish for all nested arrays to be checked then
recursemust be true - otherwise only the outermost array will be checked. This argument has no effect when operating on a one-dimension array.
Returns
- Type
Boolean- Description
Trueif the array includesSearchTypeNametype,Falseif not.
Example
Public Sub IncludesTypeExample()
Dim result As Boolean
Dim MyArray As BetterArray
Set MyArray = New BetterArray
MyArray.Push "Foo", 1.23, "Fizz", "Buzz"
result = MyArray.IncludesType("Double")
' expected output:
' result is True
End Sub