473,761 Members | 7,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help - runtime error 91 - object variable not set

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 GetNumberOfFile s()
' 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.GetFolde r(mstrFolder) ' ---- The error occurs at
this line ---
Set objFiles = objFolder.Files

mintNumFiles = 0
For Each objFile In objFiles
If UCase(Right(obj File.Name, 3)) = "JPG" Then
mintNumFiles = mintNumFiles + 1
End If
Next

End Function ' GetNumberOfFile s
Jul 17 '05 #1
1 75020
Peter wrote:
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


Dim objFSO As Object, objFolder As Object
Dim objFiles As Object, objFile As Object

Set objFolder = objFSO.GetFolde r(mstrFolder) ' ---- The error occurs at
this line ---

So that's where it occurs. objFSO is not set and is still Nothing.
Therefore, it does not have a GetFolder method and raises an error.
I don't know why you are using late binding, but you can set objFSO to a
filesystem object by using the new keyword or the CreateObject function.

Best regards
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
74326
by: Ike | last post by:
Anyone knows what cuases this under 6.0 ? -Ike
8
5479
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
2
5046
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified folder structure and naming conventions and then send a Net send message to those users telling them to rectify. The information I want to get is when you select the file/folder and then: Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
5
2471
by: David C. Allen | last post by:
I have a vb.net app that is controling excel 2000 thru the com interop interface. I have referenced the excel 9.0 library and have cut down the code in the problem subroutine to this: Dim objExcelApp As New Excel.Application objExcelApp.Quit() objExcelApp = Nothing The problem is excel is hanging in memory and has to be closed by the task
7
1570
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As Integer = 0 To LinkResults.Length - 1 With MyCurrentClass.SqlCmd_Insert_LinkVB .CommandType = System.Data.CommandType.StoredProcedure
33
7405
by: larpup | last post by:
I checked all my references prior to compiling. The mdb or mde works perfectly with full version of A2003. When running on a computer with RunTime i receive an error that a reference is broken to msoutl.olb version 9.2. Can anyone shed some light on this as I need to deploy this application as soon as possible. Any information regarding this would be greatly appreciated.
1
2854
by: bobh | last post by:
Hi All, I've been using this function which I got from here for some time now in two of my AccessXP multiusers applications and it has worked without issue until lately it has stopped functioning on several user pc's and I don't know why. I've asked our PC Services group what they changed on the pc's that this does not work on and they say 'nothing'. Well something has changed cause this did work at one time. When I step thru it in...
2
10043
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name is used to access and read the value stored in it C.A variable is allocated or deallocated in memory during runtime D.A variable can be initialized at the time of its creation or later 2. The.……types feature facilitates the definition of classes...
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.