Results 1 to 4 of 4

Thread: [RESOLVED] Loop to add list box items

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    90

    Resolved [RESOLVED] Loop to add list box items

    Hello there,

    I have attmpted a For To Next Loop and a Do While Not Loop to add all the items from my list box.
    Here's a look at both loops.

    1)
    VB Code:
    1. Private Sub List0_DblClick(Cancel As Integer)
    2. Dim s As Integer
    3. For s = 0 To List0.ListCount
    4. List1.AddItem List0.ItemData(s)
    5. Next s
    6. End Sub

    This loop adds item as desired but prompts an error message at the end.
    Run-time error 94 Invalid use of Null.

    2)
    VB Code:
    1. Private Sub List0_DblClick(Cancel As Integer)
    2. Dim i As Integer
    3. i = List0.ListCount
    4. Do While Not i = 0
    5. i = i - 1
    6. List1.AddItem List0.ItemData(i)
    7. Looo   
    8. End Sub

    This loop adds item from bottom to top since it starts from ListCount's value and - 1.

    I'll like to have my items added the correct way without the error, can anyone comment on my loops and give suggestions?
    will be more than glad to learn new ways of looping.

    Thank You


    Astro
    Last edited by Astro; Aug 30th, 2005 at 03:20 AM.

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