sublimation
asked on
Writing to text files
Hello, Experts. The code bellow writes 2 line to a text file.
open ("c:\document.txt") for output as #1
print #1, "A line of text"
print #1, "Another line of text"
close #1
How can I make the next time i add text to the file for the text to start on the third (first empty row) line?
Can somebody point me to a good VB/VBA text editing site, i need to write and read plain text and CSV text files.
Thanks
open ("c:\document.txt") for output as #1
print #1, "A line of text"
print #1, "Another line of text"
close #1
How can I make the next time i add text to the file for the text to start on the third (first empty row) line?
Can somebody point me to a good VB/VBA text editing site, i need to write and read plain text and CSV text files.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this modification to your code.
This method uses a subroutine to add(append) new text
to the file "document.txt".
Note:
The file is opened for "Append" in subroutine.
open ("c:\document.txt") for output as #1
print #1, "A line of text"
print #1, "Another line of text"
close #1
Call AddLine("Some new text")
Private Sub AddLine(ByVal newtext As String)
Open ("c:\document.txt") For Append As #1
Print #1, newtext
Close #1
End Sub
The above method uses a subroutine to append new text
to the file "document.txt".
Have Fun!!
Experts1
This method uses a subroutine to add(append) new text
to the file "document.txt".
Note:
The file is opened for "Append" in subroutine.
open ("c:\document.txt") for output as #1
print #1, "A line of text"
print #1, "Another line of text"
close #1
Call AddLine("Some new text")
Private Sub AddLine(ByVal newtext As String)
Open ("c:\document.txt") For Append As #1
Print #1, newtext
Close #1
End Sub
The above method uses a subroutine to append new text
to the file "document.txt".
Have Fun!!
Experts1
Then you can use the following code......
Private Sub Command1_Click()
Dim o As New TextFile
Dim str As String
o.TextFilePath = "c:\a.txt"
o.WriteNewLine "A line of text"
o.WriteNewLine "Another line of text"
End Sub
with many other features as well........
Imran Arshad