简体   繁体   中英

Visual Basic Keys - Data storage issue

I have a data file that has about 2 million account numbers. I would like to store them in a Collection as "Keys" and the reason why is because I want to avoid duplicate account numbers.

Is something like this possible in a VB6 application? if so what is the syntax for the declaration of the collection.

Please note I do not need any values. Just keys.

Thanks!

UPDATE:

I am trying to take a recordset with the recordset I am taking the account numbers and adding it as the Key in a dictionary however it doesn't seem to be working

Set rs_AccNo = db_Work.OpenRecordset("SELECT accno, division FROM Users")
        Set AccNoDict = CreateObject("Scripting.Dictionary")
        If Not rs_AccNo.EOF Then
            While Not rs_AccNo.EOF
                If Not AccNoDict.Exists(rs_AccNo("accno")) Then
                    AccNoDict.Add rs_AccNo("accno"), rs_AccNo("division")
                    rs_AccNo.MoveNext
                End If
            Wend
        End If

I'm not a vb expert, I used a dictionary with dummy values for a similar problem.

Public dict As Scripting.Dictionary
Public Sub Init_TradeMapDictionary()
Set dict = New Dictionary
dict.Add rownum, "dummy value"
'to print
For Each strKey In dict.Keys
    Debug.Print strKey; " ---> "; dict(strKey)
Next

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM