Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Carriage Return at the last Line. 2

Status
Not open for further replies.

baschdi

Programmer
Nov 6, 2012
5
DE
Hello all and hi to this big, intresting Forum.
Have seen some good Threads that helped me.

But now my Question... look...

Code:
db = "C:\input1.mdb"
TextExportFile = "C:\output1.csv"

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")

cn.Open _
   "Provider = Microsoft.Jet.OLEDB.4.0; " & _
   "Data Source =" & db

strSQL = "SELECT CL_Artikelstamm_Stuffe_1.Artikel, CL_Artikelstamm_Stuffe_1.Hersteller, CL_Artikelstamm_Stuffe_1.[Bezeichnung 1], CL_Artikelstamm_Stuffe_1.[Bezeichnung 2], IIf([CL_Artikelstamm_Stuffe_1]![SGueltigAb]<=Date(),IIf([CL_Artikelstamm_Stuffe_1]![SGueltigBis]>=Date(),[CL_Artikelstamm_Stuffe_1]![Sonderpreis],[CL_Artikelstamm_Stuffe_1]![Verkaufspreis 1]),[CL_Artikelstamm_Stuffe_1]![Verkaufspreis 1]) AS [Verkaufspreis 1], CL_Artikelstamm_Stuffe_1.[Verkaufspreis 2], CL_Artikelstamm_Stuffe_1.[Verkaufspreis 3], CL_Artikelstamm_Stuffe_1.[Verkaufspreis 4], CL_Artikelstamm_Stuffe_1.[Verkaufspreis 5], CL_Artikelstamm_Stuffe_1.RabattierungsKz, [CL_Verfügbarer Bestand pro Artikel].[Verfügbarer Bestand]FROM CL_Artikelstamm_Stuffe_1 INNER JOIN [CL_Verfügbarer Bestand pro Artikel] ON (CL_Artikelstamm_Stuffe_1.Hersteller = [CL_Verfügbarer Bestand pro Artikel].Hersteller) AND (CL_Artikelstamm_Stuffe_1.Artikel = [CL_Verfügbarer Bestand pro Artikel].Artikelnummer);" 

rs.Open strSQL, cn, 3, 3

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.CreateTextFile(TextExportFile, True, True)


a = rs.GetString


f.WriteLine a 

f.Close


output has a carriage Return at every Line, i need to remove that at the Last Line.


How can i do it?
 
Perhaps this ?
f.WriteLine Left(a, Len(a) - 2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
k, thx. Howto do a Carriage Return with Linefeed @ Line 100 ? Idea?
 
In fact, I have a simpler way for the original question:
f.Write a

Could you elaborate on your second question.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
or other idea, replacin the Carriage Return at every Line with vbCrLf!?
 
replacin the Carriage Return at every Line with vbCrLf
f.Write Replace(a, vbCr, vbCrLf)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Or, of course, give the correct parameters to GetString to get CRLFs instead of a CRs in the first place:

a = rs.GetString(RowDelimeter:=vbCRLF)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top