I have a program which was working fine.
In it a function works out the number of .jpg files in a specified folder.
I then realised that I needed to make sure the folder exists first & added
the code for this.
After this I get the Runtime Error 91 - Object variable not set.
I've rem'd out my added code to no avail. Tried rebooting to.
The earlier exe version of the program continues to work OK.
The code in question is shown below. I'd appriciate any advice on how I've
messed this up & how to fix it
I'm running VB6 on XP pro SP2
mstrFolder is declared at the module level and Quickwatch shows it's
contents are a valid path.
many thanks
--
Peter
To err is human but it takes a computer to really mess things up!
__________________________________________________ _______
Private Function GetNumberOfFiles()
' Returns the number of files with a "jpg" extension in the folder
mstrFolder
Dim objFSO As Object, objFolder As Object
Dim objFiles As Object, objFile As Object
Set objFolder = objFSO.GetFolder(mstrFolder) ' ---- The error occurs at
this line ---
Set objFiles = objFolder.Files
mintNumFiles = 0
For Each objFile In objFiles
If UCase(Right(objFile.Name, 3)) = "JPG" Then
mintNumFiles = mintNumFiles + 1
End If
Next
End Function ' GetNumberOfFiles