vb question

Started by
6 comments, last by RaistlinMajere 20 years, 8 months ago
Is there a way in vb6 to create or delete text files? If so please tell me.. thanks.
-----------------------------------------------------------"Shut up and eat your cheese sandwhich"
Advertisement
There is actually several ways of doing this. The most common way is by using the File System Object containted in the MS Scripting DLL - check the MSDN for more details.

Otherwise the most simplest form is by calling the kill() function to delete files and to create them use
open "C:\mytextfile.txt" for output as #1close #1


I think thats how you do it from memory


Extracting Patch....
Initializing Windows XP Update Path 2543663B....
Core Dumped, Now Installing Linux.....

----
Mike
Team AI: Http://members.iinet.net.au/~slyons/teamai

[edited by - Mike737 on August 18, 2003 2:56:56 AM]
ooohh same as BASIC..ty
-----------------------------------------------------------"Shut up and eat your cheese sandwhich"
How about going back just before the cataclysm and ask Fistandantilus!!
You should never hard-code the file handle. Try:

Dim iFile As Integer

iFile = FreeFile

Substitute iFile for the two places where the handle is hard-coded. The FreeFile function ensure you get a valid handle.

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

Yeah... here''s the basics:

to Write to a file:

ff=FreeFile
Open "C:\happy.abc" for output as ff
Write ff, StringThatIWantToWrite
Close ff

to Read a file(note, this only works for the 1st line, cant remember how to read the entire file without repeating the Input line):

ff=FreeFile
Open "C:\happy.abc" for input as ff
Input ff, StringThatIWantToFill
Close ff

And alas, to destroy a file:

Kill "C:\happy.abc"

Yeah... here''s the basics:

to Write to a file:

ff=FreeFile
Open "C:\happy.abc" for output as ff
Write ff, StringThatIWantToWrite
Close ff

to Read a file(note, this only works for the 1st line, cant remember how to read the entire file without repeating the Input line):

ff=FreeFile
Open "C:\happy.abc" for input as ff
Input ff, StringThatIWantToFill
Close ff

And alas, to destroy a file:

Kill "C:\happy.abc"
To read in a file to an array you might use this:

(Modifying Quantum''s code)

ff=FreeFile
Open "C:\happy.abc" for input as ff
While NOT EOF(ff)
Redim Preserve myArray(j)
Input ff, myArray(j)
j=j+1
Wend
Close ff
7|-|3 p057 @b0v3 i5 c3/^7i|=i3|) 1337!100|< |=0/^ j||3|/|7

This topic is closed to new replies.

Advertisement