Link to home
Start Free TrialLog in
Avatar of PhenominAL
PhenominAL

asked on

Checking for duplicate within a 2 dimensional static array

Hi, I'm trying to ask the user to enter a bookid within a text box.  But I want to verify that the entry hasn't been made.  It would caompre against the bookarray(arrayindex, 0) within the 2 dimensional array of records and if it isn't there, then go to the bottom and then add to the array the new entry.....
The array index was declared at the beginning of Dim bookarray(50, 5) As String.  Need some help. Thanks


Public Sub Readbookfile()
   
    arrayindex = 1
    Do While Not EOF(1)
        Input #1, strBookid, strBooktitle, strCat, strAuthor, strCost, strFlag
           
        bookarray(arrayindex, 0) = strBookid
        bookarray(arrayindex, 1) = strBooktitle
        bookarray(arrayindex, 2) = strCat
        bookarray(arrayindex, 3) = strAuthor
        bookarray(arrayindex, 4) = strCost
        bookarray(arrayindex, 5) = strFlag
        arrayindex = arrayindex + 1
    Loop
    Close #1
   
End Sub
ASKER CERTIFIED SOLUTION
Avatar of drnick
drnick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PhenominAL
PhenominAL

ASKER

Could that be integrated into a DO WHILE LOOP? Or am I complicating it?
such as ...

Private Sub AddRecord()
Dim Addbookid As String
       
        txtBookInfo(0).Text = Addbookid
        arrayindex = 1
       
        Do While Addbookid <> bookarray(arrayindex, 0)

just wanted to know if i'm starting on the right foot....



and I would want to add it to the last spot in the array using the ubound(bookarray(arrayindex))
no, to do-looping would be ok

that last-spot-adding:
it would maybe a good idea to resize the array by using redim with preseve before going ubound
Really? I thought REDIM and PRESERVE were only for dynamic arrays...how would you use them for static arrays?