5 Replies - 91319 Views - Last Post: 27 March 2010 - 01:23 PM Rate Topic: -----

#1 rabbit_slayer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 75
  • Joined: 30-September 07

How to I make a text file in VB6

Post icon  Posted 23 October 2007 - 12:36 AM

i am quite interesested on how to make a file by using vb06 code.
i wish to this because i might need it for my game, ypu know, for the save/load stuff.
plz, if anyone has any ideea, u are more than welcome to share it
Is This A Good Question/Topic? 0
  • +

Replies To: How to I make a text file in VB6

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to I make a text file in VB6

Posted 23 October 2007 - 05:40 AM

To create a text file in VB6 you use the CreateTextFile method of the FileSystemObject. The syntax for this is

object.CreateTextFile(filename[, overwrite[, unicode]])



Syntax Explanation:
  • Object: the name of your FSO object or folder object (This is required)
  • Filename: Name of the file you wish to create (Required)
  • Overwrite: Determine whether to overwire the existing file. A boolean value. If false and the file exists and error will be thrown (Optional).
  • Unicode: Boolean value to determine if the file is created in unicode or Ascii (normal string/text). Default is false (Optional).

Tp use it do something like

Dim newFIle
Dim FSO 
Set FSO = CreateObject("Scripting.FileSystemObject")
Set newFile = FSO.CreateTextFile("MyNewFile",true,false)



The above code will create a text file with the name of MyNewFile.Now when you want to write to your new file you would use the Write Method of the FileSystemObject like so:

   FSO.Write "Hello world!" 



Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: How to I make a text file in VB6

Posted 23 October 2007 - 12:32 PM

Instead of using the FileSystemObject you could also use VB's inbuilt File Handling Functions.
You can read my tutorial on Sequential File Handling in VB by clicking here.

Hope this helps
:)
Was This Post Helpful? 0
  • +
  • -

#4 biggs  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-February 08

Re: How to I make a text file in VB6

Posted 28 February 2008 - 01:14 PM

Will this same concept work for creating a new database or do you have to use adox
Was This Post Helpful? 0
  • +
  • -

#5 Guest_Saunders*


Reputation:

Re: How to I make a text file in VB6

Posted 27 March 2010 - 01:08 PM

Where does this save the file?
Was This Post Helpful? 0

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 465
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: How to I make a text file in VB6

Posted 27 March 2010 - 01:23 PM

"MyNewFile" is the path for example: "MyNewFile" is "C:\TestFile.txt"
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1