Escape an If...Else statement

How does one escape an If...Else statement. In VB6 one types "exit if"


Answer this question

Escape an If...Else statement

  • William Joyce

    There is no "Exit If" in VB6 or VB.NET.

    David Anton
    www.tangiblesoftwaresolutions.com
    Instant C#: VB to C# converter
    Instant VB: C# to VB converter
    Instant C++: C# to C++ converter
    Instant C++: VB to C++ converter
    Clear VB: Cleans up VB.NET code



  • Greyeye

    I'm not sure what you mean by "exit if" I know you can exit sub, or exit function but not an if statement.

    If you are talking about End if then as the last poster said you don't need it. You just need to use curly braces.

    if (condition)
    {
    // do stuff here
    }
    else if (condition2)
    {
    // do something else
    }
    else
    {
    // do something
    }

    Now.. if you are looking for the equivelant to a "break" statement to a loop but for an IF statement then there is no such thing and you do not need anything like that you should be able to handle that in your if statement conditions

  • Greig

    You don't need to. The scope of an if/else statement is determined by the use of curly brackets.
    If you omit curly brackets, the scope of each part is a single statement:

    if (someCondition)
    DoSomething1();
    else
    DoSomething2();

    Or with curlies:

    if (someCondition)
    {
    DoSomething1();
    DoSomething3();
    }
    else
    {
    DoSomething2();
    DoSomething4();
    }




  • Escape an If...Else statement