![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 6
Rep Power: 0
![]() |
Hi everyone, I have an if then else statement that contains a for loop and another if statement. It also contains another for loop and if statement after the Else part. What I want to do is jump out of the nested if. I've shown below the structure to make it easier to explain.
If For....... If...... .......................... (This is where I want to jump out of all these statements) End If Next ....................... Else For....... If....... ............................ End If Next .................. End If (This is where I want to jump to) ............................. ............................. I know that I can use Exit Sub to jump to the end of the sub, and I know I can use Exit For to jump out of a for loop but they are no use to me here. If anyone knows if it's possible to do what I want, then I could use your help. Cheers |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I think you might have to use *shudder* goto for this one.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() ![]() |
isn't there a
break; ??
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
There is - Exit For, Exit If or whatever, but he wants to break out of multiple nested statements. You could also set a flag, which it checks and breaks if it's true.
|
|
|
|
|
|
#5 |
|
Newbie
|
make procedure sub ThisIsIWantToJumpTo, and call it where you need. Don't use GOTO, if .Net got it.
__________________
Try ProjectTracking.NET tool, complete online project tracking solution. ProjectTracking.NET is designed to simplify development and management of small and medium sized projects for dislocated teams. Read more about Project Tracking here: http://www.ilumnis.com/Products/ProjectTracking.aspx |
|
|
|
|
|
#6 | |
|
Hobbyist Programmer
|
Quote:
bool exitloop = false;
if{
.......
if(exitloop) break;
if{
......
if(exitloop) break;
}
}edit: doh, i forgot i am now in the VB forums, not c++ anymore. close enough though, you get the picture right? |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|