Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need FileSystemObject Help!!!

Status
Not open for further replies.

TDogg

MIS
Dec 11, 2000
11
US
I get the compile error "User-defined type not defined" with "fso As FileSystemObject" highlighted.. Some Plz Help Me!

Const ForReading = 1
Dim fso As FileSystemObject
Dim f As File
Dim sContents As String
Dim WinDir$

WinDir$ = Environ$("windir")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso_OpenTextFile(WinDir$ & "system.ini", ForReading)
sContents = f.ReadAll
Set f = Nothing
Set fso = Nothing

If InStr(sContents, "shell=*TDDef.exe") > 0 Then
TDSC3.Show
Unload Me
Else
TDSC2.Show
Unload Me
End If

End Sub

Thanks,
-TDG
 
you need to add a reference to Microsoft Scriptin Runtime.

Go to project->references....and check it's box.
 
k.. now i get a different compile error. "Method or data member not found" n it highlights ".ReadAll" from sContents = f.ReadAll

-TDG
 
it's because you have f declared as a file object. fso.opentextfile returns a text stream object and you are assigning it to a file object. the File object does not have the method readall. Change f to:

dim f as textstream object
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top