Solved

Is there a special VB statement  to let you jump to the next iteration in a loop?

Posted on 2006-11-21
5
192 Views
Last Modified: 2010-04-30
Jump to next iteration in a loop

Say you got a loop like the one below.  How do I accomplish the same task without the goto statement?

  For Each MyControl In ControlCollection
    If TypeOf MyControl Is Whatever Then Goto SkipThisOne
    ' Provide code here to work with valid MyControl
SkipThisOne:
  Next MyControl

And, NO - I do NOT mean do as follows...

For Each MyControl In ControlCollection
        If not TypeOf MyControl Is Whatever Then
        ' Provide code here to work with valid MyControl
       end if
       Next MyControl

tia

avi

 
 
0
Comment
Question by:progtw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Expert Comment

by:drydenhogg
ID: 17985818
In terms of a built in collection type used in a for..each loop basically no. You have the choices of using program flow logic or goto statements, the latter of which I would say never use.


0
 
LVL 8

Assisted Solution

by:doobdave
doobdave earned 40 total points
ID: 17985895
Hi,
What's wrong with using the second method:
For Each MyControl In ControlCollection
        If not TypeOf MyControl Is Whatever Then
        ' Provide code here to work with valid MyControl
       end if
       Next MyControl
?

It looks like a much better solution than using thhe goto statement.

Best Regards,

David
0
 

Author Comment

by:progtw
ID: 17985937
to doobdave:

>> What's wrong with using the second method:

But there isn't a special VB statement  to let you jump to the next iteration in a loop?

avi
0
 
LVL 8

Accepted Solution

by:
drydenhogg earned 85 total points
ID: 17985955
There is no special statement that allows you to skip to next, no.
0
 

Author Comment

by:progtw
ID: 17985974
foooo-ey!

avi
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month5 days, 16 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question