Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,579 of 10,840    |
|    Peter to All    |
|    Help - runtime error 91 - object variabl    |
|    22 Jun 05 15:43:10    |
      From: gammaNO@SPAMblueyonder.co.uk              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              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca