help with button toggling shift register

Im trying to get a button to change what blocks of code is being sent to a shift register. I keep having timing problems with the button presses not triggering and having to wait different lengths of time with each different blocks of code. I just started working with arduino about a month ago for school and my teachers and I are trying to come up with lesson plans for students to learn more programing. Any help is greatly appreciated. Thank you very much.

int datapin = 2;
int clockpin = 3;
int latchpin = 4;
const int button = 7 ;
byte data = 0;
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(button, INPUT); // set Pin 7 for button input
  pinMode(datapin, OUTPUT); // datapin for shift register
  pinMode(clockpin, OUTPUT); // clock pin for shift register
  pinMode(latchpin, OUTPUT); // latch pin for register
  Serial.begin(14400);

}

void loop()
{
  buttonState = digitalRead(button); // set the analog button to a digital input

  if (buttonState != lastButtonState) {
    if (buttonState == HIGH) {            
      buttonPushCounter++;            // if the button is high add to the button counter
      Serial.println("on"); // print on in the serial monitor
      Serial.print("number of button pushes: "); //print number of button pushes
      Serial.println(buttonPushCounter);  // print button push counter
    }
    else {
      Serial.println("off");  // if button is not pressed print off
    }
  }
  lastButtonState = buttonState; // save the last button state

    if (buttonPushCounter == 2) {  // if the button push counter = 2 start ping pong
    pingPong();
  }

  if (buttonPushCounter == 3) {     // if the button counter equals 3 start oneOnAtATime.

    oneOnAtATime();
  }

  if ( buttonPushCounter == 4) {  // if the button counter equals 4 start randomLED
    randomLED();
  }

  if (buttonPushCounter == 5) {    // if the button counter equals 5 start one After Another

    oneAfterAnother();
  }


}

void shiftWrite(int desiredPin, boolean desiredState)    // send out the data to shift register


{

  bitWrite(data,desiredPin,desiredState);       // send the bits of program data

  shiftOut(datapin, clockpin, MSBFIRST, data);    // send control data to shift register

  digitalWrite(latchpin, HIGH);  // set the latch pin high
  digitalWrite(latchpin, LOW);  // set the latch pin low
}

void repeating() // each block of program data

{
  int index;
  int delayTime = 100;

  for(index = 0; index <= 7; index++)
  {
    shiftWrite(index, HIGH);
    delay(delayTime);
  }
}

void oneOnAtATime()  // block of program data 
{
  int index;
  int delayTime = 100;

  for(index = 0; index <= 7; index++)
  {
    shiftWrite(index, HIGH);
    delay(delayTime);
    shiftWrite(index, LOW);
  }

}


void pingPong() // block of program data
{
  int index;
  int delayTime = 100;

  for(index = 0; index <= 7; index++)
  {
    shiftWrite(index, HIGH);
    delay(delayTime);
    shiftWrite(index, LOW);
  }
}


void randomLED() // block of program data
{
  int index;
  int delayTime = 100;

  index = random(8);

  shiftWrite(index, HIGH);
  delay(delayTime);
  shiftWrite(index, LOW);
}

void marquee()  // block of program data
{
  int index;
  int delayTime = 208;

  for(index = 0; index <= 3; index++)
  {
    shiftWrite(index, HIGH);
    shiftWrite(index+4, HIGH);
    delay(delayTime);
    shiftWrite(index, LOW);
    shiftWrite(index+4, LOW);
  }
}

void oneAfterAnother () // block of program data

{
  int index;
  int delayTime = 100;

  for(index = 0; index <= 7; index++)

  {
    shiftWrite(index, HIGH);
    delay(delayTime);
  }

  for(index = 7; index >= 0; index--)
  {
    shiftWrite(index, LOW);
    delay(delayTime);
  }
}

Your button pin may be floating. Try:

void setup() {
  // put your setup code here, to run once:
  pinMode(button, INPUT_PULLUP); // set Pin 7 for button input

and change your code to check for buttonState == LOW

Im trying to get a button to change what blocks of code is being sent to a shift register.

You can't send blocks of code to a shift register. You send data to a shift register.

sorry haven't been able to reply. Thank you very much for the input !!

I just fixed my code and now everything works great thank you so much everybody!!!