Touch screen will not display variable

I am having a problem with my code. I have a script that is suppose to display the on/off times of two valves. This shows up all ok. The touch screen has two buttons > and +.
When selecting the > button the screen highlights the next time either hour or min’s for one of the valves. Then when selecting the + button I can adjust the time up.
This all works great for the first valve for on and off times. but on valve 2 when I get to the off min time it does not update.
The screen some times stays on 1.
I have added extra valves up to 4 in total all all update for On Hr & min and off Hr but not off min.

I cant work out what is going wrong.

Currently this is running on the mega with 3.2" TFT screen

Below is a cut down portion of my script. which does not work on V2 Min Off update.

Any help please

#include <UTFT.h>
#include <ITDB02_Touch.h>
#include <UTFT_Buttons_ITDB.h> 

UTFT    myGLCD(SSD1289,38,39,40,41);
ITDB02_Touch        myTouch(6,5,4,3,2);
UTFT_Buttons  myButtons(&myGLCD, &myTouch);

extern uint8_t SmallFont[];
int bplus, bneg, forward, back, pressButton; // button variables
int var[8]; // hold time settings
int a;  // used to change digits selected in settings page
char* leadingZero[]={"00","01","02","03","04","05","06","07","08","09"}; // used to display number below 0 correct

#define green 0x07E0
#define white 0xFFFF

void setup() {

  Serial.begin (9600);
  myGLCD.InitLCD();
  myGLCD.clrScr();
  myTouch.InitTouch(1);
  myTouch.setPrecision(PREC_MEDIUM);
  myGLCD.setBackColor(0, 0, 0);
  boolean default_color = true;
  myButtons.setTextFont(SmallFont);
  myGLCD.setColor(white); // set white
  myGLCD.setFont(SmallFont);
  bplus = myButtons.addButton( 165,  160, 65,  30, "+"); // add up button
  forward = myButtons.addButton( 85,  160, 65,  30, ">"); // move to next digit button
  a = 1; // set a to start at 1
  settingsPage ();  // initial setup page

}

void loop() {
  Serial.println (a);
  Serial.println (var[a]);
  settingUpdate (); // update page with current selected time and add up when + button operated
  if (myTouch.dataAvailable() == true){
    pressButton = myButtons.checkButtons();
    // if > button operated then add on one to variable a which will later highlight the next digits to be updated. 
      if (pressButton == forward){
        a = a +1;
        if (a == 10){
          a = 1;
        }
      }
      // if + button operated add 1 to var[a]
      if (pressButton == bplus)
      {
            var[a] = var[a] +1;
        }
    }
} 

void settingUpdate () {


// This code writes the times on the page for on and off for each valve

// V1 ON times
// var[1] Hour
// var[2] Minute

    if (a == 1)
      myGLCD.setColor(green);
    else
      myGLCD.setColor(white);
   if (var[1] < 10)    
      myGLCD.print (leadingZero[var[1]], 100, 40);
   else
      myGLCD.printNumI (var[1], 100, 40);
         if (a == 2)
      myGLCD.setColor(green);
   else
      myGLCD.setColor(white);
   if (var[2] < 10)    
      myGLCD.print (leadingZero[var[2]], 123, 40);
   else
      myGLCD.printNumI (var[2], 123, 40);

// V1 OFF times
// var[3] Hour
// var[4] Minute
 
   if (a == 3)
      myGLCD.setColor(green);
    else
      myGLCD.setColor(white);
   if (var[3] < 10)    
      myGLCD.print (leadingZero[var[3]], 255, 40);
   else
      myGLCD.printNumI (var[3], 255, 40);
  if (a == 4)
      myGLCD.setColor(green);
   else
      myGLCD.setColor(white);
   if (var[4] < 10)    
      myGLCD.print (leadingZero[var[4]], 280, 40);
   else
      myGLCD.printNumI (var[4], 280, 40);
      
// V2 ON times
// var[5] Hour
// var[6] Minute

   if (a == 5)
      myGLCD.setColor(green);
    else
      myGLCD.setColor(white);

   if (var[5] < 10)    
      myGLCD.print (leadingZero[var[5]], 100, 60);
   else
      myGLCD.printNumI (var[5], 100, 60);
  if (a == 6)
      myGLCD.setColor(green);
   else
      myGLCD.setColor(white);
   if (var[6] < 10)    
      myGLCD.print (leadingZero[var[6]], 123, 60);
   else
      myGLCD.printNumI (var[6], 123, 60);

// V2 OFF times
// var[7] Hour
// var[8] Minute
 
   if (a == 7)
      myGLCD.setColor(green);
    else
      myGLCD.setColor(white);
   if (var[7] < 10)    
      myGLCD.print (leadingZero[var[7]], 255, 60);
   else
      myGLCD.printNumI (var[7], 255, 60);
  if (a == 8)
      myGLCD.setColor(green);
   else
      myGLCD.setColor(white);
   if (var[8] < 60)    
      myGLCD.print (leadingZero[var[8]], 280, 60);
   else
      myGLCD.printNumI (var[8], 280, 60);

}
void settingsPage (){

  myGLCD.print ("V1 ON Time ", 10, 40);
  myGLCD.print (":", 115, 40);
  myGLCD.print ("V1 OFF Time", 160, 40);
  myGLCD.print (":", 272, 40);
  myGLCD.print ("V2 ON Time ", 10, 60);
  myGLCD.print (":", 115, 60);
  myGLCD.print ("V2 OFF Time", 160, 60);
  myGLCD.print (":", 272, 60);  
  myButtons.drawButton(bplus);
  myButtons.drawButton(forward);
}

Also when uploaded and I operate the > arrow the V2 OFF Min time displays lines. wired

I’ve stripped this back further to the following code

void loop() {

  
    for (int i=1; i<15; i++){
      var[7] = i;
      delay (500);
      settingUpdate ();
    }

    for (int i=1; i < 15; i++){
      var[8] = i;
      delay (500);
      settingUpdate ();
    }
}

void settingUpdate () {

   if (var[7] < 10)    
      myGLCD.print (leadingZero[var[7]], 255, 60);
   else
      myGLCD.printNumI (var[7], 255, 60);


   if (var[8] < 60)    
      myGLCD.print (leadingZero[var[8]], 280, 60);
   else
      myGLCD.printNumI (var[8], 280, 60);

}

This displays two sets of number’s the first var[7] counts to 15 all ok and displays all ok. the second set numbers var[8] only gets to 9 then goes to a load off ###

Is this because I am using an array?

I’ve worked out what is causing it

   myGLCD.print (leadingZero[var[8]], 280, 60);

So I need to remove this but I need something to add in to give 0 in front of single digits

Is this because I am using an array?

No, it is because you are misusing the array. The array contains 8 elements, numbered 0 to 7. There is NO var[8]. You are crapping on memory that you don't own.