For simple cases, VB's Select construct can be converted to the Java switch construct. However, if any of the Case statements include range or non-constant expressions, then the equivalent is an if/else block.
VB | Java |
---|---|
'converts to switch: Select Case x Case 0 ... Case 1 ... End Select 'converts to if/else: Select Case x Case 1 To 3 ... Case Is < 10, Is > 20, Is = 15 ... End Select |
//converts to switch: switch (x) { case 0: //... break; case 1: //... break; } //converts to if/else: if (x >= 1 && x <= 3) { ... } else if ((x < 10) || (x > 20) || (x == 15)) { ... } |
Use VB to Java Converter to convert from VB to Java.
Additional resource:
VB.NET and Java Equivalents
Copyright © 1997 – 2019 Tangible Software Solutions, Inc.