Results 1 to 3 of 3

Thread: [RESOLVED] break from 'if' loop

  1. #1

    Thread Starter
    Addicted Member BIOSTALL's Avatar
    Join Date
    Apr 2005
    Location
    Northampton, UK
    Posts
    180

    Resolved [RESOLVED] break from 'if' loop

    Hey I'm trying to exit from an 'if' loop but i cant find the right way to do it. I've heard of 'break' but this is only for while, for, foreach, switch etc etc. not 'if'. Can anyone please help??

    Many thanks, BIOSTALL

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: break from 'if' loop

    You cannot break out of an IF statement. What you can do though is enclose the IF statement inside a function and use return to escape from it.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: [RESOLVED] break from 'if' loop

    IF is not even a loop.

    However, when I have a block where I sometimes prematurely have to jump to the end, I sometimes do this:
    Code:
    do {
    
    ...
    ...
    ...
    // Uh-oh, need to jump
    if($total_disaster) break;
    
    ...
    ...
    
    } while(false);
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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