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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSytemObject - Help 1

Status
Not open for further replies.

dwlerwill

Technical User
May 25, 2001
329
0
0
Can someone go though how you add a FileSytemObject to VB6

I'm trying to use the following code

Private Sub Command1_Click()

Dim fs As New FileSytemObject
Dim MyTxt As TextStream

MyTxt = fs.OpenTextFile("C:\Test1.txt", forwriting)

MyTxt.WriteLine Text1.Text
MyTxt.Close
End Sub


But it just says User-defined type defined.

I have click on on add Microsoft Runtime Scripting but once that is selected don't know what to do next.

 
Ammend the following line to sinclude the SET keyword:

MyTxt = fs.OpenTextFile("C:\Test1.txt", forwriting)

as follows
SET MyTxt = fs.OpenTextFile("C:\Test1.txt", forwriting)

Chris Dukes
 
Did that and still get User-defined type Not defined with this row highlighted

fs As New FileSytemObject
 
If you make sure that the scripting runtime is selected in the refernces dialog then the only other thing I can see is the wrong spelling of FileSystemObject.

Also you'll prbably need to put in:

Set MyTxt = fs.opentextFile("C:\Test1.txt",forWriting)

or a with block error comes up.

Hope this helps

David
 
It now works, Thanks for your help I don't know what was wrong I Just pasted over my line with the one you put.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top