Results 1 to 13 of 13

Thread: How do I use the FileSystemObject in VB6 Professional?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    How do I use the FileSystemObject in VB6 Professional?

    I'm working in Visual Basic 6 Professional on Windows XP Home (I believe it's the "Home" version), and I found out that VB6 is supposed to have something called the FileSystemObject. I read it here:
    http://articles.techrepublic.com.com...1-1050078.html

    It says that you are supposed to invoke it with this code:
    Code:
    Dim fso As New FileSystemObject
    But I can't get it to work. Can someone PLEASE help me with this.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: How do I use the FileSystemObject in VB6 Professional?

    The FSO is part of Windows Scripting, not VB6. Of course you can use it within VB6 as easily as from VBScript.

    You can't declare an object reference of that type until you set a reference to the library. This library is called Microsoft Scripting Runtime.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by dilettante
    The FSO is part of Windows Scripting, not VB6. Of course you can use it within VB6 as easily as from VBScript.

    You can't declare an object reference of that type until you set a reference to the library. This library is called Microsoft Scripting Runtime.

    Is Microsoft Scripting Runtime something that comes with Windows XP Home? Or does it only come in the more expensive versions of XP? Or is it something I can just download anyway?

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: How do I use the FileSystemObject in VB6 Professional?

    I would think it comes with the Visual Studio installation since I can also use it in XP Home...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,663

    Re: How do I use the FileSystemObject in VB6 Professional?

    You need to set a reference to it first.

    Click on the: Projects>>References Menu

    and locate 'Microsoft Scripting Runtime' from the list.

    Then Declare:

    Dim fso As FileSystemObject

    Then in form_load you could have:

    Set fso As New FileSystemObject
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  6. #6
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: How do I use the FileSystemObject in VB6 Professional?

    Check my, BackupDisk, for , "Dim fso As FileSystemObject

    example

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by some1uk03
    You need to set a reference to it first.

    Click on the: Projects>>References Menu

    and locate 'Microsoft Scripting Runtime' from the list.

    Then Declare:

    Dim fso As FileSystemObject

    Then in form_load you could have:

    Set fso As New FileSystemObject
    I saw somewhere someone used "Dim" and "As New" in the same line, like
    Code:
    Dim fso As New Filesystem Object
    instead using the "Dim fso As" and "Set fso As New" in 2 separate lines. Why do you use the 2 separate lines?

  8. #8
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: How do I use the FileSystemObject in VB6 Professional?

    some1uk03 mixed it up, it is not

    Code:
    Set fso As New FileSystemObject
    It should be

    Code:
    Set fso = New FileSystemObject
    Have a look at this for instantiation explanations...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by dee-u
    some1uk03 mixed it up, it is not

    Code:
    Set fso As New FileSystemObject
    It should be

    Code:
    Set fso = New FileSystemObject
    Have a look at this for instantiation explanations...
    I still can't figure out how to get "Filesystemobject" to be the list of "New" things. So do I need to reinstall VisualStudio? When I installed it to start with, I just installed VB6 (no C++ or J or any of the other stuff.

    And why use "Set" before making "fso" equal to something? I just set all of my variables with the equals sign by itself, like a=100.
    I never say Set a=100.

  10. #10
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: How do I use the FileSystemObject in VB6 Professional?

    Have you installed SP6 already? If not then try installing it and check in it is already there...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,181

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by dee-u
    Have you installed SP6 already? If not then try installing it and check in it is already there...
    I thought that when I installed VB6 Professional it came with everything it should have.

    When I look in the components manager (allows you to add controls to a project that aren't already on the toolbar), and I found one that says "Microsoft Windows Common Controls 6.0 (SP6)". So I assume that means I have SP6 on here.

    Is the problem maybe that I'm running VB6 (not VB .Net) on a Windows XP computer? I heard that VB .Net was supposed to be just for Windows XP. But since a lot of the good commands were removed in the new Visual Basic, I'm sticking with VB6 Professional.

  12. #12
    Junior Member
    Join Date
    Sep 2008
    Posts
    26

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by Ben321
    I saw somewhere someone used "Dim" and "As New" in the same line, like
    Code:
    Dim fso As New Filesystem Object
    instead using the "Dim fso As" and "Set fso As New" in 2 separate lines. Why do you use the 2 separate lines?
    Both of 2 statements are mostly the same. But the Dim fso As New XXX is slow performance that compared to Dim FSO as XXXX : Set FSO= New XXXX

  13. #13
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,123

    Re: How do I use the FileSystemObject in VB6 Professional?

    Quote Originally Posted by Ben321
    I thought that when I installed VB6 Professional it came with everything it should have.
    I am not exactly sure but just recently I have been fiddling with the VB6.0 installed in my home computer and it was lacking some controls like RichTextbox and others, I just installed SP6 and all of them was back again. I have not been able to use the VB6.0 installed in my computer for quite some time so I am not sure if those controls existed with my first install or maybe I have uninstalled them accidentally by other means...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width