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 atFromIndex
for positive values ofFromIndex
, or at the array’sLength
property +FromIndex
for negative values ofFromIndex
(using the absolute value ofFromIndex
as the number of characters from the end of the array at which to start the search). Defaults to the array’sLowerBound
property.
- 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
recurse
must 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
True
if the array includesSearchTypeName
type,False
if 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