brLocate method

Searches for the location of a specific element (passed as a clsD3DynamicArray object) in a clsD3DynamicArray object.

Syntax

bValue = object.brLocate( oDynArrayFind, nFound, [ vnAMC], [ vnVMC], [ vnStart])

Parameters

Parameter Description
bValue The return value is a Boolean data type that is True if oDynArrayFind is found in object.
object An object variable that represents a clsD3DynamicArray object to be searched.
oDynArrayFind A clsD3DynamicArray object that contains the specific element to be found.
nFound A Long indicating the position where oDynArrayFind was found. If not found, this variable defaults to the end of the dynamic array. This is an output-only parameter.
vnAMC Optional. A Variant (Integer subtype) specifying the attribute mark count to be searched.
vnVMC Optional. A Variant (Integer subtype) specifying the value mark count to be searched.
vnStart Optional. A Variant (Integer subtype) specifying the first field from which to begin the search.

Remarks

The use of the optional parameters, vnAMC and vnVMC, indicate whether the value returned into nFound is a value count or a sub-value count. If both vnAMC and vnVMC are omitted, the value returned into nFound is an attribute count.

The optional parameter, vnStart, is the first field to search, which may be an attribute, value or sub-value depending upon the use of vnAMC and vnVMC. If vnAMC and vnVMC are both nonzero, then vnStart is the first sub-value to be searched. If vnAMC is nonzero and vnVMC is zero, then vnStart is the first value to be searched. If both vnAMC and vnVMC are zero, then vnStart is the first attribute searched.

This method has the same functionality as brLocateStr. The difference between the two methods is the way the element to be located is passed. In the brLocate method, the element is passed as a clsD3DynamicArray object (oDynArrayFind). In the brLocateStr method the element is passed as a string.

Example

Sub Main()
   Dim oEnv As New clsD3Environment
   Dim oConn As clsD3Connection
   Dim oArray As New clsD3DynamicArray
   Dim oContinent As New clsD3DynamicArray
   Dim lFound As Long
 
   Set oConn = oEnv.brOpenConnection("ODBC", "production”)
 
   oArray.brCString = "Europe" & D3VMChr & "South America" & D3VMChr & "Africa" 
   oContinent.brCString = InputBox("Enter a continent")
   If oArray.brLocate(oContinent, lFound, 1) = True Then
      oContinent.brCString = InputBox(oContinent.brCString & " is already there. Enter replacement")
      oArray.brReplace oContinent, 1, lFound
   Else
      oArray.brInsert oContinent, -1
   End If
 
   MsgBox oArray.brCString
 
   oEnv.brCloseConnection oConn
   Set oArray = Nothing
   Set oContinent = Nothing
   Set oEnv = Nothing
End Sub

FlashBASIC reference

locate – without a sequence parameter