Results 1 to 9 of 9

Thread: array help[resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    94

    array help[resolved]

    ok this might be confusing to some but ill try to explain it the best that i can.

    i have an array, if something is found in the array that i don't want, is there a way for me to ignore it, but continue the array?

    if i put exit sub it totally halts the whole array.

    any ideas? thanks!
    Last edited by Fragment; Sep 18th, 2004 at 11:43 PM.

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I'll have to make assumptions here - I am assuming you are looping thru an array, maybe loading up a listbox or something. But if you come across an item in the array that you DON'T want in the listbox or whatever, you want to ignore it and continue on. If this is the case, you can use code like this:
    VB Code:
    1. For X = LBound(MyArray) To UBound(MyArray)
    2.     If MyArray(X) = "JUNK" Then
    3.         ' do nothing
    4.     Else
    5.         ' use MyArray(X) as required, for example:
    6.         List1.AddItem MyArray(X)
    7.     End If
    8. Next
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    94
    o ahahaha ya, that way works too .

    jeez i'm dumb. thanks

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    you could also use an EXIT FOR statement.

    Add [Resolved] to the subject of the first post to close it.

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    Fragment - glad to help.
    dglienna - Exit For would cause him the same problem that he wrote about - it would cease processing of the array ...
    "It's cold gin time again ..."

    Check out my website here.

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    oops. meant EXIT IF. didn't see his code, just wanted to explain a few options.

  7. #7
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    David -
    Hate to beat a dead horse, but "Exit If" does not exist ...
    "It's cold gin time again ..."

    Check out my website here.

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    oops. ignore that one.

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Now you understand the If structure, you could take BruceG's example to the next level like:
    VB Code:
    1. For X = LBound(MyArray) To UBound(MyArray)
    2.     If MyArray(X) <> "JUNK" Then List1.AddItem MyArray(X)
    3. Next




    Bruce.

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