for each go next?

  • Thread starter Thread starter Guoqi Zheng
  • Start date Start date
G

Guoqi Zheng

Ok, it sounds like a simple question but I just can not figure out how to do
it.

I use for each to loop an arraylist, what I want is that in case of some
condition is ture, it skip the rest code and go to next for.

for example.

For each x in arylist

If a =b THEN
' here I want to skip the pare of "do something here" below, then go the
next for each.
' how can I do it????
END

..... do something here....

Next
 
This is the case for a 'Continue' statement. However, this is not available
in framework version 1.0 and 1.1. But it will be available in framework v2.0.
Check out here: http://msdn2.microsoft.com/library/801hyx6f.aspx

For now, you can look at it the other way around and write the code as:

For each x in arylist
if a <> b then
' do something here..
end if
Next

or you could use labels to accomplish this.

hope that helps..
Imran.
 
For each x in arylist

If a =b THEN
' here I want to skip the pare of "do something here" below, then go the
next for each.
' how can I do it????
END

VB 2005 includes a Continue keyword for this. In earlier versions, you
typically do

For each x in arylist

If a <> b Then
' do somehting here
End If

Next



Mattias
 
Back
Top