Write Data Into A Text File Using VB6 / Classic
The following example shows how you can write the following three lines of data into a textfile ( .txt) using Visual Basic. Assuming the text file "contact.txt" is to be stored in C:\ drive.
----------------------contact.txt---------------------
Michael Dee
880-488-7178887
789 Island Street, PO Box 88, Hamburg, PA 19526
------------------------------------------------------
Dim FileNum As Integer
Dim data As String
FileNum = FreeFile
On Error Goto ErrorHandler
Open "C:\contact.txt" For Output As #FileNum '---Create (if not exists) / Open file for writing
data = "Michael Dee"
Print #filenum, data '---Write line 1
data = "880-488-7178887 "
Print #filenum, data '---Write line 2
data = "789 Island Street, PO Box 88, Hamburg, PA 19526"
Print #filenum, data '---Write line 3
ErrorHandler:
Close #filenum '---Close the file after writing
Now the three line of data has been written and stored into the text file in Visual Basic.
See also how to Read Data From A Text File Using VB6 / Classic
See also how to Read Data From A Text File Using VB.NET
See also how to Write Data Into A Text File Using VB.NET
VB6 : Write Data Into A Text File
Posted by Fluffy | 8:49 PM | VB6, Write Data Into A Text File VB6 | 0 comments »
Subscribe to:
Post Comments (Atom)

0 comments
Post a Comment