As Richard mentioned, you are out of bounds because you are subtracting 1 from the months variable when accessing the daysInMonth array in the While loop. This can cause the index to become negative, or to exceed the bounds of the array.
For example, when months is equal to 1, the expression months - 1 will evaluate to 0, which is a valid index for the daysInMonth array. However, when months is equal to 0, the expression months - 1 will evaluate to -1, which is an invalid index for the array.
To fix this issue, you can adjust the condition in the While loop to check if days is greater than or equal to the number of days in the current month -
While days >= daysInMonth(months - 1)
days -= daysInMonth(months - 1)
months += 1
If months = 13 Then
years += 1
months = 1
End If
Wend