FindArray

Purpose
Used to find the index number of a record containing specified data.

Syntax (Read-Only Property)
Long = object.FindArray(Data, Instance, Options)

Parameters
Data (String)   The data to search for.
Instance (Long)  

This is the instance of the record containing the specified data you want to find.

Data and Instance work together to find a record. For example, if Instance is 3, then the property finds the 4th (zero-based) record that contains the data Data.

This parameter is zero-based.

Negative values are bound to zero (0).

Options (rtCDP_FindOptions [Long])   A value from the ENum rtCDP_FindOptions that affects that way the search is performed.

Return Value
Long (Long)  

The record number of the record matching the search criteria.

This value is zero-based.

Notes
If a record is found that matches the search criteria, the property returns the record number of the matching record.

If no record is found that matches the search criteria, the property returns -1.

If Options enters as an invalid value, the property returns -1.

If an error occurs, the property returns -1.

If Data is passed a zero-length string, the property will return the record number of the specified instance of a record containing a zero-length string. This property does not assume that a zero-length string matches any record in the database like some database systems do.

Error Values
After calling this function, the property ErrorNumber will report one of the following values:

rtCDP_ErrNoError
rtCDP_ErrDataTooLong
rtCDP_ErrRecordNotFound
rtCDP_ErrInvalidOptions

Example
Objective: Build a short list and then search for specific data.

'Create the object
Dim CDP As rtCDP.rtCompactDataPak
Set CDP = New
rtCDP.rtCompactDataPak
'Append 6 new records
CDP.Append "", "
Journey"
CDP.Append "", "
Robert Palmer"
CDP.Append "", "Journey"
CDP.Append "", "Rossington Collins Band"
CDP.Append "", "Blues Brothers"
CDP.Append "", "Journey"

This is the current state of the database:

Rec Key Data
0 . Journey
1 . Robert Palmer
2 . Journey
3 . Blues Traveller
4 . .Blues Brothers
5   Journey

'Search for records
Dim RecNum
As Long
RecNum = CDP.FindArray("Blues Brothers ", 0, rtCDP_FindDefault)
'...RecNum = 4
RecNum = CDP.FindArray("Blues", 1, rtCDP_FindDefault)
'...RecNum = -1

RecNum = CDP.FindArray("Blues", 1, rtCDP_FindWithin)
'...RecNum = 4

RecNum = CDP.FindArray("Journey", 2, rtCDP_FindDefault)
'...RecNum = 5
RecNum = CDP.FindArray("Journey", 3, rtCDP_FindDefault)
'...RecNum = -1

Version History
1.0 2/21/2001 Tested

See Also
Find, FindB, FindArrayB, FindRec, FindRecB