Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   FileSystemObject (http://www.programmingforums.org/showthread.php?t=15466)

Abyss Mar 23rd, 2008 12:43 PM

FileSystemObject
 
Hello All, I was wondering if someone could help explain this piece of VB code to me? I've read about the FileSystemObject online but the 'rfs' function is a bit confusing. Any help is appreciated.

Thanks

:

Function rfs(filespec)
  Dim fso, Msg
  Set fso = CreateObject("Scripting.FileSystemObject")
  If (fso.FileExists(filespec)) Then
    Msg = "YES"
  Else
    Msg = "NO"
  End If
  rfs = Msg
End Function


Abyss Mar 23rd, 2008 12:52 PM

Re: FileSystemObject
 
Actually, I understand that the rfs function is taking in say, a string like for example C:Windows\Notepad.exe"and it's checking if that file exists...just not sure about the

:

Set fso = CreateObject("Scripting.FileSystemObject")

Hmm...

null_ptr0 Mar 23rd, 2008 8:57 PM

Re: FileSystemObject
 
Scripting.FileSystemObject is an activex control object, and the function returns whether or not the argument filespec exists.
it should be (i believe):
:

Function rfs(ByVal filespec As String) As String
  Dim fso, Msg
  Set fso = CreateObject("Scripting.FileSystemObject")
  If (fso.FileExists(filespec)) Then
    Msg = "YES"
  Else
    Msg = "NO"
  End If
  rfs = Msg
End Function



All times are GMT -5. The time now is 12:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC