Can you help me telling me where my mistake is?
Yes. You said "this doesn't work". That's useless information. The program does something. While its running, you do something. You expect the code to do something.
We don't know what any of those things are.
How IS your switch wired?
Creating a new variable, buttonNumber, on every pass through loop() is probably NOT what you want to be doing. Make it static or global.