CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    5

    Forceing a for-loop to exit

    I searched around and couldn't find anything on the subject.

    My code looks a little like this ....

    Code:
    for(int i = 0; i < array->count; i++)
    {
         if(some condition)
         {
              do stuff // Activate a tool tip
              (this is where I want to force the for loop to exit)
         }
         else
         {
              do other stuff // deActivate a tool tip
         }
    }
    The problem is after the tool tip is activated in the if statement, if the for loop runs again then it is deActivated in the else statement.

    So what I want to be able to do is exit out of the for loop inside of the if statement.

  2. #2
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658

    Re: Forceing a for-loop to exit

    use the break statement.

    search: loops break continue
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  3. #3
    Join Date
    Apr 2007
    Posts
    5

    Re: Forceing a for-loop to exit

    Thankyou
    That worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured