Results 1 to 5 of 5

Thread: Need Help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    NC
    Posts
    12

    Question

    I need to Display all of the items in a list box onto a Label control! Does anyone have an idea about how to do this! I tried using a Do Until loop but it doesn't stop and it displays the first item then when it loops it displays the next and the first one is no longer there! Please help!

    Thanks

    Jamie

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    NC
    Posts
    12

    Tried it and it didn't work!

    Here's the code!

    Private Sub cmdCheckOut_Click()
    Dim I As Integer
    Dim c As Integer
    c = List1.ListCount
    I = List1.ListIndex

    Do Until List1.ListIndex = List1.ListCount


    Label4.Caption = List1.List(I)
    I = I + 1

    Loop

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175
    This line of code is the problem

    Label4.Caption = List1.List(I)

    You are telling VB to replace the label's content every time you loop.

    Do this instead

    Label4.Caption = Label4.caption & List1.List(I)

    or

    Label4.Caption = Label4.caption & List1.List(I) & vbCrLF


    They both tell VB to append the new vale to what is already there.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Location
    NC
    Posts
    12
    Thanks! Now All I have to do is figure out how to stop it! I'm just learning and this is an assignment so I'll keep digging into my books!

    Thanks again

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