I need help with a little code entry pad.

Are your buttons labled 2 to 10 ? Because that is what you are compairing attempt to.
Y can get greater than 2 so you over run the array, it needs fixing. By restricting what Y can be.