Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 12th, 2004, 9:16 AM   #1
masanovic
Newbie
 
Join Date: Nov 2004
Posts: 6
Rep Power: 0 masanovic is on a distinguished road
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
masanovic is offline   Reply With Quote
Old Dec 12th, 2004, 11:28 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I think you might have to use *shudder* goto for this one.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 12th, 2004, 11:25 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
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."
Infinite Recursion is offline   Reply With Quote
Old Dec 13th, 2004, 11:41 AM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Dec 16th, 2004, 4:45 AM   #5
bunker
Newbie
 
Join Date: Dec 2004
Location: Serbia
Posts: 4
Rep Power: 0 bunker is on a distinguished road
Send a message via ICQ to bunker
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
bunker is offline   Reply With Quote
Old Feb 16th, 2005, 1:22 AM   #6
melbolt
Hobbyist Programmer
 
melbolt's Avatar
 
Join Date: Feb 2005
Location: PA, USA
Posts: 237
Rep Power: 4 melbolt is on a distinguished road
Send a message via AIM to melbolt Send a message via Yahoo to melbolt
Quote:
Originally Posted by Ooble
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.
that's how i'd do it too. just set up a flag(boolean variable) called exitloop or something. in each loop you will need a if(exitloop) then break.

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?
melbolt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC