|
-
Sep 18th, 2004, 07:07 PM
#1
Thread Starter
Lively Member
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.
-
Sep 18th, 2004, 07:13 PM
#2
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:
For X = LBound(MyArray) To UBound(MyArray)
If MyArray(X) = "JUNK" Then
' do nothing
Else
' use MyArray(X) as required, for example:
List1.AddItem MyArray(X)
End If
Next
"It's cold gin time again ..."
Check out my website here.
-
Sep 18th, 2004, 07:36 PM
#3
Thread Starter
Lively Member
o ahahaha ya, that way works too .
jeez i'm dumb. thanks
-
Sep 18th, 2004, 09:04 PM
#4
you could also use an EXIT FOR statement.
Add [Resolved] to the subject of the first post to close it.
-
Sep 19th, 2004, 09:35 AM
#5
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.
-
Sep 19th, 2004, 12:18 PM
#6
oops. meant EXIT IF. didn't see his code, just wanted to explain a few options.
-
Sep 19th, 2004, 12:31 PM
#7
David -
Hate to beat a dead horse, but "Exit If" does not exist ...
"It's cold gin time again ..."
Check out my website here.
-
Sep 22nd, 2004, 11:45 PM
#8
-
Sep 22nd, 2004, 11:57 PM
#9
Now you understand the If structure, you could take BruceG's example to the next level like:
VB Code:
For X = LBound(MyArray) To UBound(MyArray)
If MyArray(X) <> "JUNK" Then List1.AddItem MyArray(X)
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|