cArray: Exists

Exists

Uses a callback method to check if an element in an array exists.



 Public Function Exists(
	  ByRef Arr As Variant,
	  ByVal AddressOfMatch As Long ) As Boolean

Parameters

Arr
[ByRef] Variant. The array to check if an element exists according to the callback criteria.
AddressOfMatch
[ByVal] Long. The AddressOf the callback method used to determine if an element matches the specified criteria.

Return Values

Boolean -  Indication of the element existing in the array.

Remarks

Each array element is passed into a user callback method. The user then checks the element value to determine if it matches any criteria necessary and returns the result. The criteria is defined outside of the Exists method. How the criteria is defined and checked is up to the user of the function.

The function signature for the callback has a specific format.

 Public Function ExistsCallback(ByRef x As [Array Datatype]) As Boolean
     ' return True if x matches your criteria.
 End Sub
 
The [Array Datatype] must be replaced with the datatype of the array. If the array is an array of Variants, then [Array Datatype] would be a Variant, not any specific sub-type within the variants of the array.

See Also

Project VBCorLib Overview Class cArray Overview cArray Properties cArray Methods CreateInstance Find