CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: collections

  1. #1
    Join Date
    Apr 2001
    Location
    Chicago, IL
    Posts
    27

    collections

    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

  2. #2
    Join Date
    Aug 2000
    Location
    Namibia
    Posts
    139

    Re: collections

    Declare item to be of type variant or object
    Change this Dim item as string


    To this Dim item as variant




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured