Can someone tell me how to write a loop to count the number of files in an array??
Printable View
Can someone tell me how to write a loop to count the number of files in an array??
Kanejone. You can use the Ubound Function to get the number of files without having to loop through the array.All the best.Code:lFilesCount = (Ubound(YourFilesArray) + 1)
you don't need a loop if they are in an array
file count would be
msgbox "My file count = " & uBound(myArray)-1
'minus 1 as arrays are zero based
HeSaidJoe,wouldn't you need to add 1 because of this to get the file count? For example if the array contained 2 files, subtracting 1 from UBound would give a file count of 0, whereas adding 1 would give a file count of 2.Quote:
'minus 1 as arrays are zero based
All the best.
Your're right (Add 1)
..it's those cheap drugs..
Gotta get a raise so I can get better ones.
LOL
Later
Maybe you should lay off of the drugs for a while! ;)