473,855 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Next iteration in a for loop?


Is there any way to "skip" iterations in a for loop?

Example :

for x = 1 to 10

if something = 1
next
endif

next

I see the Exit For, but I just need to skip iterations sometimes, not
jump out all together.

Thanks!

--
- Mitchell Vincent
- kBilling - Invoices Made Easy!
- http://www.k-billing.com
Nov 21 '05
23 22024
Sorry, still not following. That wasn't rewriting the loop I had to be
equivalent and with no continue.

The first example had an 'Exit While'. but that is not the same as having a
'Continue' there. And I'm not really sure what the second one was supposed
to be doing...

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Marina,

Reading it over, as always, you are right,

:-)

Therefore see bellow.

Probably this is not the one you want.

\\\See the real one behind this
While condition
While 1 = 1 'faking
If var1 = 1 Then
Dim v1 As Integer = 1 + 1
If var2 = 2 Then
Dim v2 As Integer = 1 + 1
ElseIf var3 = 5 Then
Exit While
End If
Dim v3 As Integer = 1 + 1
Else
Dim v4 As Integer = 1 + 1
End If
Dim v As Integer = 1 + 1
End While
End While
///

\\\ However I find this more readable
While condition
If var1 = 1 Then
Dim v1 As Integer = 1 + 1
If var2 = 2 Then
Dim v2 As Integer = 1 + 1
ElseIf var3 <> 5 Then
Dim v3 As Integer = 1 + 1
End If
Else
Dim v4 As Integer = 1 + 1
End If
If var3 <> 5 Then
Dim v As Integer = 1 + 1
End If
End While
///

I have not really tested the last one.
However the point is the extra condition which tell when it should be
done.

Cor

Nov 21 '05 #21
Dennis wrote:
I've been programming (both as hobby and at times professionally) before most
of you were born and I find GoTo's very useful in some situations...be ats me
why one would type several characters of code when a few would do nicely just
to maintain their "programmin g religion".. Might want to try Assembler
programming without GoTo's (Jumps as they are sometimes called).


It's always "the best tool for the job" for me. Sometimes that is a
GoTo, sometimes it isn't!

I think the religion surrounding GoTo started because it was being
overused and misused, kind of funny how that happens!

--
- Mitchell Vincent
- kBilling - Invoices Made Easy!
- http://www.k-billing.com
Nov 21 '05 #22
Marina,

It does not exit the while it restart the outerloop and is only exiting the
innerloop which is endless.

The second sample shows without that restarting the loop a nicer
documentative use.

Cor
Nov 21 '05 #23
Hi

So I think this is also an alternative to workaround the problem besides If
statement.
Also in vb.net 2005, there will be a new keyword Continue added.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4865
by: DottingTheNet | last post by:
Hi ppl!! just a newbie ques is there something in PL/SQL that skips to the next iteration in the for loop like a next, etc.???? Thnx!!
4
2714
by: Christopher Benson-Manica | last post by:
I have a situation something like this: int foo; for( foo=bar() ; foo <= bar()+1 ; foo++ ) { if( !baz(foo) ) break; /* do stuff with foo */ } The idea is that the loop happens at most twice - once for foo=bar(), and once
2
3561
by: Marc Miller | last post by:
Is there any way in VB to force the next iteration in a For ... next loop other than using a GoTo? I notice that in C++ you can use 'continue' and in other languages there are syntax for this. Am I missing something? For an example, if a = false I don't want the if b = true to execute. for i = 1 to 10
0
9754
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10692
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10767
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9526
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7927
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7084
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4168
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.