Click to See Complete Forum and Search --> : collections


Archie
June 14th, 2001, 12:53 PM
Does anyone know what changes I need to make to the code below so that it does not give me an error that says "For each control variable must be Variant or Object. Thank you for your help.

Dim myColl As New Collection
Private Sub cmdAdd_Click()
If Len(txtInput) > 0 Then
myColl.Add txtInput
txtInput = ""
End If
End Sub

Private Sub cmdDisplay_Click()
Dim item As String
lstOutput.Clear

For Each item In myColl
lstOutput.AddItem item
Next item

End Sub
Private Sub Form_Load()
Set myColl = New Collection
End Sub


Archie Kantzavelos

phunkydude
June 14th, 2001, 01:03 PM
Declare item to be of type variant or object
Change this Dim item as string


To this Dim item as variant