B
BruceM
I have code that I borrowed from Allen Browne to loop through folder and
subfolder contents recursively. Actually, I adapted it to search for a
particular file that includes a specific text string in the file name. If
the file is not found I want to tell the user. Without getting into the
details of the code, the subfolders to be searched are added to a collection
for which I can determine the count. Each time through the code I increment
a variable. If the variable equals the subfolder count and the file is not
found I generate an informational message. If I do not increment the
variable the message appears after every subfolder.
My question is what is a good way to establish a variable that starts with
the value of 0 by default? I have this at the start of the procedure:
Dim varCount as Variant
I added a watch on varCount and noted that its value is Empty. From various
tests, including adding one to varCount and noting that its new value is
equal to one, it seems that varCount can be treated as a 0 initially, but I
don't know if this is reliable. I can't figure out how to assign the
variable an initial value without having it reset to that value each time
through the code, so I hope there is a reliable way to use the default
variable.
I have also seen:
Static intCount as Integer
which also seems to start at 0.
subfolder contents recursively. Actually, I adapted it to search for a
particular file that includes a specific text string in the file name. If
the file is not found I want to tell the user. Without getting into the
details of the code, the subfolders to be searched are added to a collection
for which I can determine the count. Each time through the code I increment
a variable. If the variable equals the subfolder count and the file is not
found I generate an informational message. If I do not increment the
variable the message appears after every subfolder.
My question is what is a good way to establish a variable that starts with
the value of 0 by default? I have this at the start of the procedure:
Dim varCount as Variant
I added a watch on varCount and noted that its value is Empty. From various
tests, including adding one to varCount and noting that its new value is
equal to one, it seems that varCount can be treated as a 0 initially, but I
don't know if this is reliable. I can't figure out how to assign the
variable an initial value without having it reset to that value each time
through the code, so I hope there is a reliable way to use the default
variable.
I have also seen:
Static intCount as Integer
which also seems to start at 0.