Results 1 to 7 of 7

Thread: [VB6] Going through listbox items and looping my commands.

  1. #1
    SmileYaDead's Avatar
    Join Date
    Feb 2012
    Gender
    Age
    27
    Posts
    3,605
    Thanks
    802
    Thanked 812 Times in 453 Posts


    Downloads
    96
    Uploads
    0
    Mentioned
    352 Post(s)
    Time Online
    80 d 17 h 14 m
    Avg. Time Online
    1 h 1 m
    Rep Power
    11

    [VB6] Going through listbox items and looping my commands.

    I've been working on a program for a few days and I think I'm almost done, but since this is all my coding experience, I'm not good and rely mostly on tutorials. I just need some help getting my listbox items to be chosen automatically, at the moment I have to click on each one of the items and then click on the command button to get it to work. Should I use a different approach for the text list itself or..?

    Also, looping is somehow a problem for me -.-

    Thanks

  2. #2

    Join Date
    Jan 2012
    Gender
    Location
    Atlanta
    Age
    25
    Posts
    136
    Thanks
    1,372
    Thanked 1,399 Times in 817 Posts


    Downloads
    85
    Uploads
    4
    Mentioned
    628 Post(s)
    Time Online
    14 d 7 h 24 m
    Avg. Time Online
    10 m
    Rep Power
    6
    Idk about VB6, but it Java, you use a for each loop.

    I'm sure someone will give you an exact answer, but look up for each loops.

  3. #3
    Banned
    Join Date
    Dec 2011
    Gender
    Location
    Kiwiland
    Posts
    264
    Thanks
    22
    Thanked 106 Times in 68 Posts


    Downloads
    22
    Uploads
    0
    Mentioned
    74 Post(s)
    Time Online
    N/A
    Avg. Time Online
    N/A
    Rep Power
    0
    Do until x = lstBox.listcount - 1
    code here
    x = x + 1
    loop

  4. The Following User Says Thank You to Joshsadf For This Useful Post:

    SmileYaDead (03-29-2012)

  5. #4
    Little Brother


    Zachafer's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    1,206
    Thanks
    723
    Thanked 1,392 Times in 651 Posts


    Downloads
    81
    Uploads
    17
    Mentioned
    497 Post(s)
    Time Online
    21 d 17 h 32 m
    Avg. Time Online
    16 m
    Rep Power
    14
    Quote Originally Posted by Josh View Post
    Do until x = lstBox.listcount - 1
    code here
    x = x + 1
    loop
    Better version:


    Or even a for loop:


    In these cases, x is an index of the listbox.
    You access the string in the listbox by lstBox.List(index)
    Last edited by Zachafer; 03-29-2012 at 08:16 PM.

  6. The Following User Says Thank You to Zachafer For This Useful Post:

    SmileYaDead (03-29-2012)

  7. #5
    SmileYaDead's Avatar
    Join Date
    Feb 2012
    Gender
    Age
    27
    Posts
    3,605
    Thanks
    802
    Thanked 812 Times in 453 Posts


    Downloads
    96
    Uploads
    0
    Mentioned
    352 Post(s)
    Time Online
    80 d 17 h 14 m
    Avg. Time Online
    1 h 1 m
    Rep Power
    11
    Thanks, I'll put this in tomorrow, need some sleep.

  8. #6
    SmileYaDead's Avatar
    Join Date
    Feb 2012
    Gender
    Age
    27
    Posts
    3,605
    Thanks
    802
    Thanked 812 Times in 453 Posts


    Downloads
    96
    Uploads
    0
    Mentioned
    352 Post(s)
    Time Online
    80 d 17 h 14 m
    Avg. Time Online
    1 h 1 m
    Rep Power
    11
    How would these be in the VB 2010 version?

  9. #7
    Little Brother


    Zachafer's Avatar
    Join Date
    Dec 2011
    Gender
    Posts
    1,206
    Thanks
    723
    Thanked 1,392 Times in 651 Posts


    Downloads
    81
    Uploads
    17
    Mentioned
    497 Post(s)
    Time Online
    21 d 17 h 32 m
    Avg. Time Online
    16 m
    Rep Power
    14
    Quote Originally Posted by smileyadead View Post
    How would these be in the VB 2010 version?
    Close to the same:



    Or even a for loop:


    In these cases, x is an index of the listbox.
    You access the string in the listbox by lstBox.Items(index)

Posting Permissions

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