Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

RaistlinMajere

vb question

This topic is 5591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 #1
close #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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!