FileSystemObject question

  • Thread starter Thread starter jodyblau
  • Start date Start date
J

jodyblau

I am using a FileSystemObject in my access databas. I am much more
familiar with programming in C++ than I am in Visual Basic.

My question is this.
I seem to have to create a FileSystemObject as follows:
Dim FSys As New FileSystemObject

Since I use the "New" keyword, do I need to delete teh
FileSystemObject when I am done, (as I would want to do if using C++ ?)
or does visual basic manage the memory for me?

Thanks,

Jody Blau
 
I am using a FileSystemObject in my access databas. I am much more
familiar with programming in C++ than I am in Visual Basic.

My question is this.
I seem to have to create a FileSystemObject as follows:
Dim FSys As New FileSystemObject

Since I use the "New" keyword, do I need to delete teh
FileSystemObject when I am done, (as I would want to do if using C++
?) or does visual basic manage the memory for me?

Thanks,

Jody Blau

If you declare the object in local scope, not at module level in a
standard module, then it will be destroyed automatically when the
procedure exits. At least, that's the way it's *supposed* to work. I
still think it's a good idea to make sure, by stating

Set FSys = Nothing

when you're done with it. Some people take issue with this "belt and
suspenders" approach, and that's their prerogative.
 
Any particular reason you're using FSO? VBA is capable of doing just about
everything FSO can do, without the overhead of linking to the FSO library.

Also, it's generally considered to be better to use

Dim FSys As FileSystemObject

Set FSys = New FileSystemObject



than

Dim FSys As New FileSystemObject
 
Back
Top