Run-time error: 9 - subscript out of range 2

0

Hi! I'm having problems with this error. I believe that there is some problem in the data that I inserted, but I can not fix it.

     Calcul des cumuls annuels sur l'année hydrologique (1er septembre au 31 aout)

  For k = 1 To nbannees - 1
     For j = 1 To 12
         PluieAnnHy(k) = PluieAnnHy(k) + PluieMens(12 * (k - 1) + 8 + j)
         ETPAnnHy(k) = ETPAnnHy(k) + ETPMens(12 * (k - 1) + 8 + j)
         TemperAnnHy(k) = TemperAnnHy(k) + TemperMens(12 * (k - 1) + 8 + j)
         DebitAnnHy(k) = DebitAnnHy(k) + DebitMens(12 * (k - 1) + 8 + j)
          If dataneige_exist = True Then NeigeAnnHy(k) = NeigeAnnHy(k) + 
  NeigeMens((12 * (k - 1) + 8 + j))
  Next
  TemperAnnHy(k) = TemperAnnHy(k) / 12
  DebitAnnHy(k) = DebitAnnHy(k) / 12
    
asked by anonymous 21.12.2017 / 16:45

1 answer

1

What I notice first is that the internal for does not have its respective next try the code below.

         ' Calcul des cumuls annuels sur l'année hydrologique (1er septembre au 31 aout)

  For k = 1 To nbannees - 1
     For j = 1 To 12
         PluieAnnHy(k) = PluieAnnHy(k) + PluieMens(12 * (k - 1) + 8 + j)
         ETPAnnHy(k) = ETPAnnHy(k) + ETPMens(12 * (k - 1) + 8 + j)
         TemperAnnHy(k) = TemperAnnHy(k) + TemperMens(12 * (k - 1) + 8 + j)
         DebitAnnHy(k) = DebitAnnHy(k) + DebitMens(12 * (k - 1) + 8 + j)
          If dataneige_exist = True Then
            NeigeAnnHy(k) = NeigeAnnHy(k) + NeigeMens((12 * (k - 1) + 8 + j))
          End If
    Next j
  Next k

  TemperAnnHy(k) = TemperAnnHy(k) / 12
  DebitAnnHy(k) = DebitAnnHy(k) / 12
    
07.01.2018 / 02:22