Find

Returns the member IDs of those members of a member list with labels that match a search string. Each time a member matching the search criteria is found, the member ID of the member and the member ID of its parent are returned.

The pbFoundMatch argument returns a Boolean that indicates the success of the find operation, thus allowing you to loop until all occurrences are found, as shown in the example.

Syntax

<IHsvTreeInfo>.Find lListID, lTopMemberID, bstrSearchText, bForward, plPos, plMemberID, plParentID, pbFoundMatch

Argument

Description

lListID

Long (ByVal). Identifies either the default dimension hierarchy or a member list. Pass the HFMConstants type library constant MEMBER_LIST_ALL_HIERARCHY to search the default hierarchy, or a valid list ID to search a member list.

You can get member list IDs with GetMemberListID.

lTopMemberID

Long (ByVal). The usage of this argument depends on what you pass to the lListID argument:

  • If you pass MEMBER_LIST_ALL_HIERARCHY to lListID, you can either search the entire dimension hierarchy by passing the HFMConstants type library constant TREE_ROOT, or search a node’s members by passing the member ID of the node’s parent.

  • If you pass anything other than MEMBER_LIST_ALL_HIERARCHY to lListID, the lListTopMemberID argument is ignored. Note that since this argument is not optional, you must still pass a valid Long.

bstrSearchText

String (ByVal). The search string. Pass all or part of the labels of the members for which the search is being conducted.

If you pass a partial label, Find will search for all members that begin with the passed string.

bForward

Boolean (ByVal). Indicates whether the search will go forwards or backwards in the dimension hierarchy or member list. Pass TRUE to search forwards, FALSE to search backwards.

plPos

Long. Sets the starting position of the search within the dimension hierarchy or member list, and returns a number that should be passed to the next call to Find. Use this argument as follows:

  1. To start a search for a string, pass -1.

  2. For each subsequent search for the string, pass the number returned in the previous call to Find (as shown in the example).

plMemberID

Long. If a member label is found that matches the search string, this argument returns the member ID of the member.

plParentID

Long. If a member label is found that matches the search string, this argument returns the member ID of the member’s parent.

pbFoundMatch

Boolean. Returns TRUE if a member label is found that matches the search string, otherwise FALSE.

Example

The following subroutine prints to Visual Basic’s Immediate window the labels of all members of a given dimension and member list that partially match the specified string. The example also prints labels of parent members.

Sub printListMatch(iDim As Integer, lListId As Long, _
   sDesc As String)
Dim lPos As Long, cTreeInfo As IHsvTreeInfo, lMem As Long
Dim lPar As Long, bRet As Boolean, sMemLabel As String
Dim sParLabel As String
'g_cMetadata is an HsvMetadata object reference
Set cTreeInfo = g_cMetadata.Dimension(iDim)
lPos = -1
bRet = True
Do
  cTreeInfo.Find lListId, TREE_ROOT, sDesc, True, lPos, _
     lMem, lPar, bRet
  If bRet = True Then
    cTreeInfo.GetLabel lMem, sMemLabel
    cTreeInfo.GetLabel lPar, sParLabel
    Debug.Print sMemLabel & "  " & sParLabel
  End If
Loop Until bRet = False
End Sub