You are trying to loop through an array, by starting at 0 and going up to the number of items. You are getting the number of items, and then trying to use that to get a specific item (the last one) from the array itself, you just need the number of items. I can easily give you the code, but I have given you everything you need to solve it yourself .

Here are some examples:

For intProfLoop As Integer = 0 To UBound(intProfileLinks) - 1

For intIndex As Integer = 0 To intBaseFolderRefs.Length - 1