Results 1 to 4 of 4

Thread: Backward Looping!

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Question Backward Looping!

    Assume that a menu has 50 items & I want to unload all the 50 items when a CommandButton is clicked. If I use the following code:
    VB Code:
    1. Private Sub cmdDelete()
    2.     Dim i As Integer
    3.  
    4.     For i = 0 To mnuMovies.UBound
    5.         Unload mnuMovies(i)
    6.     Next i
    7. End Sub
    Then only 49 menu items get unloaded; the very first item still remains but if I use this code:
    VB Code:
    1. Private Sub cmdDelete()
    2.     Dim i As Integer
    3.  
    4.     For i = mnuMovies.UBound To 1 Step -1
    5.         Unload mnuMovies(i)
    6.     Next i
    7. End Sub
    Then all the 50 menu items get unloaded. Why doesn't the first code snippet unload all the menu items?


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Backward Looping!

    well i'm surprised you even get that first one two work. Presumably in that array the first member was created at design time and you can't unload controls created at design time.

    VB Code:
    1. For i = 1 To mnuMovies.UBound
    2.         Unload mnuMovies(i)
    3.     Next i
    works just fine

  3. #3

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Backward Looping!

    Yes, you are very much correct but in that case, how does the second code snippet in post #1 unload the first item in the menu which has been created at design time?


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,728

    Re: Backward Looping!

    It is not possible.
    Check if your other code is hiding mnuMovies(0).
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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