+ Reply to Thread
Results 1 to 6 of 6

how to print my collection to the immediate window

  1. #1
    Forum Contributor
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    2016
    Posts
    710

    how to print my collection to the immediate window

    doing something wrong as the last for next loop errors out. can someone tell me what i am doing wrong?

    Please Login or Register  to view this content.
    it errors out on the print statement

  2. #2
    Forum Expert
    Join Date
    08-13-2008
    Location
    behind you
    MS-Off Ver
    2010 primarily
    Posts
    1,317

    Re: how to print my collection to the immediate window

    What are you expecting it to print? Currently you've told it to print an object, which won't work. It's also generally better to use a For Each loop with a collection.
    Rory

    "I hate quotations. Tell me what you know." -Emerson

  3. #3
    Forum Contributor
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    2016
    Posts
    710

    Re: how to print my collection to the immediate window

    thanks @rorya

    yup, i see that now. so i changed the code to this:

    Please Login or Register  to view this content.
    but now its printing the same Name 312 times, can you tell me why?

  4. #4
    Forum Contributor
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    2016
    Posts
    710

    Re: how to print my collection to the immediate window

    so i changed the for next loop to a for each loop like so, but still getting the same name printed 312 times

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-11-2018
    Location
    Gurgaon
    MS-Off Ver
    XP
    Posts
    10

    Re: how to print my collection to the immediate window

    Quote Originally Posted by rorya View Post
    What are you expecting it to print? Currently you've told it to print an object, which won't work. It's also generally better to use a For Each loop with a collection.
    Thanks rorya for clearing the doubt.

  6. #6
    Forum Expert
    Join Date
    08-13-2008
    Location
    behind you
    MS-Off Ver
    2010 primarily
    Posts
    1,317

    Re: how to print my collection to the immediate window

    You're adding the same object each time.

    First off, never use Dim ... As New ...

    Dim the variable normally, then use:

    Please Login or Register  to view this content.
    inside your loop, so that you create a new instance each time, and add that to the collection.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1