Switch case?

warren631:
What is wrong with this code and how else should it be done? I can do this in VB:

You can do ranges. This compiles:

void setup ()
{
int distance;
  
   switch (distance) {
    case 0 ... 10:
      Serial.println("far away");
      break;
    case 11 ... 50:
      Serial.println("within sight");
      break;
    case 51 ... 100:
      Serial.println("slow down");
      break;
    case 101 ... 200:
      Serial.println("almost there");
      break;
    default: 
      Serial.println("stop!");
      break;
  }

}
void loop () {}