FIND in array

User avatar
sal21
PlatinumLounger
Posts: 4402
Joined: 26 Apr 2010, 17:36

FIND in array

Post by sal21 »

i can use thei code to find in array?

InStr(1, Join((eccc...))

i fill the array with:

Code: Select all

Private Sub FILL_ELAB_ARRAY()

    Dim VALORE As String
    SQL = "SELECT ELAB, GIORNO FROM DATE_ELAB"
    Set RS = New ADODB.Recordset
    RS.CursorLocation = adUseClient
    RS.Open SQL, CON, adOpenForwardOnly, adLockReadOnly
    RS.Sort = ("GIORNO")
    
    If Not (RS Is Nothing) Then
        If (RS.State And adStateOpen) = adStateOpen Then RST.Close
        Set RS = Nothing
    End If
    
    Erase ELAB_ARRAY()

    Do While Not RS.EOF
        VALORE = RS.Fields(0).Value & "-" & RS.Fields(1).Value
        ReDim Preserve ELAB_ARRAY(I)
        ELAB_ARRAY(I) = VALORE
        RS.MoveNext
    Loop
    
    If Not (RS Is Nothing) Then
        If (RS.State And adStateOpen) = adStateOpen Then RST.Close
        Set RS = Nothing
    End If

End Sub

User avatar
HansV
Administrator
Posts: 78794
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: FIND in array

Post by HansV »

Since you populate the array in a loop, you might check for the value you want to find in that loop.
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 593
Joined: 27 Jun 2021, 10:46

Re: FIND in array

Post by SpeakEasy »

Why not just use the recordset directly?