Computing.Net > Forums > Programming > VB Create Txt file, single line iss

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB Create Txt file, single line iss

Reply to Message Icon

Name: Sean_CAD
Date: July 30, 2008 at 09:22:24 Pacific
OS: Windows XP
CPU/Ram: na
Product: na
Comment:

I am creating text files that consist of a single line of data. But once the file is complete, there is an extra "Blank" line. Is there any way to get rid of this extra blank line??

Code:
Function ExportFileSystem()
Dim counter As Long
Dim rs As New ADODB.Recordset
Dim sql As String
Dim Dpath As String
Dim Spath As String
Dim fso As New Scripting.FileSystemObject
Dim txtfile As String
Dim txtstr As TextStream

sql = "Select * from [Sample]"
counter = 1

Dpath = "N:\test\"

rs.Open sql, CurrentProject.Connection

Do Until rs.EOF
'Create FLD File
txtfile = Dpath & rs("volume") & "\" & rs("NEW BATCH ID") & ".txt"
Set txtstr = fso.OpenTextFile(txtfile, ForWriting, True, TristateUseDefault)
txtstr.WriteLine rs("Site")
txtstr.Close
rs.MoveNext
Loop
rs.Close
MsgBox "done"
End Function


Problem:
The text file is all correct, but after the line from the rs("Site") there is a blank line. Making the text file two lines.

Example:
SITE 'line1
'line 2 < there is a blank here. This is what i need to get rid of.



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 30, 2008 at 17:30:38 Pacific
Reply:

Try using txtstr.Write instead. If you find things are all jumbled on a single line after the change, you're looking at the output on a platform that does not handle MS' new line syntax well.


0

Response Number 2
Name: Sean_CAD
Date: July 31, 2008 at 08:11:25 Pacific
Reply:

Yeah that did it. Thanks so much!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB Create Txt file, single line iss

With Batch create .txt file www.computing.net/answers/programming/with-batch-create-txt-file/9975.html

Creating a file with header www.computing.net/answers/programming/creating-a-file-with-header/19149.html

Creating a variable from a txt file www.computing.net/answers/programming/creating-a-variable-from-a-txt-file/16486.html