SuperPeanut SuperPeanut - 1 year ago 77 Question

Is there a VB .NET equivalent to C Fall Through switch?

This is not a duplicate of this question : VB.NET Stacking Select Case Statements together like in Switch C#/Java. The answer provided here does not answer my question. The answer there is stating that there is an automatic break in VB .Net, which I'm aware of. I'm asking if there's any workaround.

In C, it is possible to do something like this :

int i = 1;
switch (i) {
case 1 :
//Do first stuff
case 2 :
//Do second stuff
//Fall Through
case 3 :
//Do third stuff


  • If
    is 1, app will do first stuff.

  • If
    is 2, it will do second AND third stuff.

  • If
    is 3, it will do only third stuff.

Since there is an auto break at the end of each
Select case
statement in VB .Net, does anyone know how to achieve this in VB .Net ?

In a nice and pretty way I mean...

Answer Source

Your premise is wrong. In C# you can't fall through to the next case if the current case has statements. Trying to do so will result in a compilation error.

You can, however, (ab)use goto case to get this working.

    case 0:
        goto case 1;
    case 1:


VB.Net has no equivalent of goto case