Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > fso type mismatch


Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2002, 02:36 AM
basdewaard's Avatar
basdewaard basdewaard is offline
Centurion
 
Join Date: Jul 2001
Location: Perth, Western Australia
Posts: 174
Default fso type mismatch


Anyone else get a type mismatch on the 'CreateTextFile'?
It works for 'OpenTextFile'


Code:
Private Sub Command1_Click() Dim fso As New FileSystemObject Dim f As File Dim ts As TextStream 'Create a new file Set f = fso.CreateTextFile("C:\test.txt") Set ts = f.OpenAsTextStream(ForAppending) ts.Write "TEST" ts.Close Set f = Nothing Set ts = Nothing End Sub
Reply With Quote
  #2  
Old 11-06-2002, 02:50 AM
Optikal's Avatar
Optikal Optikal is offline
Codeaholic

Retired Leader
* Guru *
 
Join Date: Oct 2002
Location: Winnipeg, MB, Canada
Posts: 4,543
Default

Why use FSO. Just do Open "C:\test.txt" For Output As #1
__________________
There are 10 types of people in this world, those that understand binary, and those that don't.
Reply With Quote
  #3  
Old 11-15-2002, 01:48 AM
basdewaard's Avatar
basdewaard basdewaard is offline
Centurion
 
Join Date: Jul 2001
Location: Perth, Western Australia
Posts: 174
Default

Thanks. I am well aware that the Open statement is an (often simpler) alternative.

I'm trying to find out whether or not FSO is working as it should.
FSO was created to provide specific advantages over the older file I/O statements and functions, the obvious one being object-oriented cababilities.

The 'simplicity' of my post was designed to focus on a specific feature/problem.
Reply With Quote
  #4  
Old 11-15-2002, 02:48 AM
Sysdev2 Sysdev2 is offline
Regular
 
Join Date: Nov 2002
Location: Birmingham, UK
Posts: 84
Default

Check out the object browser. The CreateTextFile method returns a TextStream object, not a File object...
__________________
"People who have silly sayings as signatures are boring and sad !"
Reply With Quote
  #5  
Old 11-19-2002, 11:09 PM
basdewaard's Avatar
basdewaard basdewaard is offline
Centurion
 
Join Date: Jul 2001
Location: Perth, Western Australia
Posts: 174
Default

Ahh. Bingo. Thank you very much. That was helpfull!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->