-
I am trying to load into a collection the key and member from a file. When I run the program I get "Key already associated error" any suggestions on this code?
Private Sub Form_Load()
Dim mcollTerms As New Collection
Dim strTerms As String 'key
Dim strDefine As String 'member
Dim j As Integer
Dim Temp As String
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
Open "a:\computerTerms.gls" For Input As #1
Dim obj As Variant
For Each obj In mcollTerms
mcollTerms.Remove 1
Next obj
Do While Not EOF(1)
mcollTerms.Add strDefine, strTerms
lstTerms.AddItem strTerms
Loop
lstTerms.ListIndex = 1
Close #1
Thanks
Kelly
-
<?>
You forgot you input from your file:
Do While Not EOF(1)
Input #1, strDefine, strTerms 'get the stuff from file
mcollTerms.Add strDefine, strTerms
-
still getting error:
Open "a:\computerTerms.gls" For Input As #1
Dim obj As Variant
For Each obj In mcollTerms
mcollTerms.Remove 1
Next obj
Do While Not EOF(1)
Input #1, strDefine, strTerms
mcollTerms.Add strDefine, strTerms ('error here already associated key)
lstTerms.AddItem strTerms
Loop
lstTerms.ListIndex = 1
Close #1
-
thanks HeSaidJoe
there was some other syntex probs. but got it reading and inputting the file. All I need to do now is code my click event in the list box to pull up the member that goes with the key.
Thaks agian
Kelly