Find

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

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

Parameters
Data (String)   The data to search for.
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 first 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 4 new records
CDP.Append "", "Robert Palmer"
CDP.Append "", "Rossington Collins Band"
CDP.Append "", "Journey"
CDP.Append "", "Blues Brothers"
CDP.Append "", ""

This is the current state of the database:

Rec Key Data
0 . Robert Palmer
1 . Rossington Collins Band
2 . Journey
3 . Blues Brothers
4 . .

'Now, find some records
Dim RecNum As Long
RecNum = CDP.Find("Journey", rtCRT_FindDefault)
'RecNum = 2
RecNum = CDP.Find("journey", rtCRT_FindDefault) 'RecNum = -1
RecNum = CDP.Find("Journey", rtCRT_FindNoCase) 'RecNum = 2
RecNum = CDP.Find("Collins", rtCRT_FindDefault) 'RecNum = -1
RecNum = CDP.Find("Collins", rtCRT_FindWithin) 'RecNum = 1
RecNum = CDP.Find("collins", rtCRT_FindWithin) 'RecNum = -1
RecNum = CDP.Find("collins", rtCRT_FindWithin + rtCRT_FindNoCase)
' ...RecNum = 1
RecNum = CDP.Find("", rtCRT_FindDefault) 'RecNum = 4