![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | appending/writing to a file Is there a way to write to a .txt file at a specific location so that it is readable. Each of the variables PN, refdes, qty, load have different lengths. I am using the following statement: objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & vbCR But its a long file and I would like to see it all well aligned so that it is readable. thanks, SA |
My System Specs![]() |
| | #2 (permalink) |
| | Re: appending/writing to a file "sa" <agarwasa2008@xxxxxx> wrote in message news:10d47d3e-9b62-46af-b7c4-c9aaff2888cc@xxxxxx Quote: > Is there a way to write to a .txt file at a specific location so that > it is readable. Each of the variables PN, refdes, qty, load have > different lengths. I am using the following statement: > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & > vbCR > > But its a long file and I would like to see it all well aligned so > that it is readable. > > thanks, > SA difference which application you use! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: appending/writing to a file On Nov 18, 11:27*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "sa" <agarwasa2...@xxxxxx> wrote in message > > news:10d47d3e-9b62-46af-b7c4-c9aaff2888cc@xxxxxx > Quote: > > Is there a way to write to a .txt file at a specific location so that > > it is readable. Each of the variables PN, refdes, qty, load have > > different lengths. I am using the following statement: Quote: > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & > > vbCR Quote: > > But its a long file and I would like to see it all well aligned so > > that it is readable. Quote: > > thanks, > > SA > Readable by what? Notepad.exe? Excel? MS Word? Other? It makes a big > difference which application you use! Here's a sample of my output: ------------------------------------------ 4711-10077 CR0102 1 03 083100015 C2 1 05 4711-10077 C7,CR101,CR102 3 02 4711-10077 CR103,CR104 2 02 4711-10077 CR105 1 02 4711-10077 C11 1 01 4711-10077 C3 1 02 083100015 C3 1 0139271529 What I would like to see is as follows (ie the columns are aligned in the .txt file) -------------------------------------------------------------------------------------------------- 4711-10077 CR0102 1 03 083100015 C2 1 05 4711-10077 C7,CR101,CR102 3 02 4711-10077 CR103,CR104 2 02 4711-10077 CR105 1 02 4711-10077 C11 1 01 4711-10077 C3 1 02 083100015 C3 1 0139271529 |
My System Specs![]() |
| | #4 (permalink) |
| | Re: appending/writing to a file On Nov 18, 12:24*pm, sa <agarwasa2...@xxxxxx> wrote: Quote: > On Nov 18, 11:27*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: > > > > > Quote: > > "sa" <agarwasa2...@xxxxxx> wrote in message Quote: > >news:10d47d3e-9b62-46af-b7c4-c9aaff2888cc@xxxxxx Quote: Quote: > > > Is there a way to write to a .txt file at a specific location so that > > > it is readable. Each of the variables PN, refdes, qty, load have > > > different lengths. I am using the following statement: Quote: Quote: > > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & > > > vbCR Quote: Quote: > > > But its a long file and I would like to see it all well aligned so > > > that it is readable. Quote: Quote: > > > thanks, > > > SA Quote: > > Readable by what? Notepad.exe? Excel? MS Word? Other? It makes a big > > difference which application you use! > Sorry about that . Its a *.txt file: > > Here's a sample of my output: > ------------------------------------------ > 4711-10077 * * *CR0102 *1 * * * 03 > 083100015 * * * C2 * * *1 * * * 05 > 4711-10077 * * *C7,CR101,CR102 *3 * * * 02 > 4711-10077 * * *CR103,CR104 * * 2 * * * 02 > 4711-10077 * * *CR105 * 1 * * * 02 > 4711-10077 * * *C11 * * 1 * * * 01 > 4711-10077 * * *C3 * * *1 * * * 02 > 083100015 * * * C3 * * *1 * * * 0139271529 > > What I would like to see is as follows (ie the columns are aligned in > the .txt file)re of another way to > ---------------------------------------------------------------------------*----------------------- > 4711-10077 * * *CR0102 * * * * *1 * * *03 > 083100015 * * * *C2 * * * * * * 1 * * 05 > 4711-10077 * * *C7,CR101,CR102 * 3 * * *02 > 4711-10077 * * *CR103,CR104 * * 2 * * *02 > 4711-10077 * * *CR105 * * * * * 1 * * *02 > 4711-10077 * * *C11 * * * * * * 1 * * *01 > 4711-10077 * * *C3 * * * * * * * 1 * * *02 > 083100015 * * * C3 * * * * * * * 1 * * 0139271529 What I wanted did not show correctly but I want the report to have the Partnumber, RD's, qty and Loadoption to be aligned. I am using vbTAB and am not sure of another to present this data neatly in .txt file |
My System Specs![]() |
| | #5 (permalink) |
| | Re: appending/writing to a file "sa" <agarwasa2008@xxxxxx> wrote in message news:3cfcfc83-a77e-468c-89bb-60913c75ca4c@xxxxxx On Nov 18, 11:27 am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "sa" <agarwasa2...@xxxxxx> wrote in message > > news:10d47d3e-9b62-46af-b7c4-c9aaff2888cc@xxxxxx > Quote: > > Is there a way to write to a .txt file at a specific location so that > > it is readable. Each of the variables PN, refdes, qty, load have > > different lengths. I am using the following statement: Quote: > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & > > vbCR Quote: > > But its a long file and I would like to see it all well aligned so > > that it is readable. Quote: > > thanks, > > SA > Readable by what? Notepad.exe? Excel? MS Word? Other? It makes a big > difference which application you use! Here's a sample of my output: ------------------------------------------ 4711-10077 CR0102 1 03 083100015 C2 1 05 4711-10077 C7,CR101,CR102 3 02 4711-10077 CR103,CR104 2 02 4711-10077 CR105 1 02 4711-10077 C11 1 01 4711-10077 C3 1 02 083100015 C3 1 0139271529 What I would like to see is as follows (ie the columns are aligned in the .txt file) -------------------------------------------------------------------------------------------------- 4711-10077 CR0102 1 03 083100015 C2 1 05 4711-10077 C7,CR101,CR102 3 02 4711-10077 CR103,CR104 2 02 4711-10077 CR105 1 02 4711-10077 C11 1 01 4711-10077 C3 1 02 083100015 C3 1 0139271529 ====================== If you want your columns neatly aligned in a text file using a fixed pitch character set then you should use spaces to pad them out rather than tabs. Instead of coding objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & vbCR you might code like so: objFile.Writeline pad(PN) & pad(refdes) & pad(qty) & pad(load) Function pad (sWord) If Len(sWord) >= 10 Then pad = sWord Else pad = sWord & Space(10 - Len(sWord)) End If End Function |
My System Specs![]() |
| | #6 (permalink) |
| | Re: appending/writing to a file On Nov 18, 12:59*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "sa" <agarwasa2...@xxxxxx> wrote in message > > news:3cfcfc83-a77e-468c-89bb-60913c75ca4c@xxxxxx > On Nov 18, 11:27 am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: > > > > > Quote: > > "sa" <agarwasa2...@xxxxxx> wrote in message Quote: > >news:10d47d3e-9b62-46af-b7c4-c9aaff2888cc@xxxxxx Quote: Quote: > > > Is there a way to write to a .txt file at a specific location so that > > > it is readable. Each of the variables PN, refdes, qty, load have > > > different lengths. I am using the following statement: Quote: Quote: > > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & > > > vbCR Quote: Quote: > > > But its a long file and I would like to see it all well aligned so > > > that it is readable. Quote: Quote: > > > thanks, > > > SA Quote: > > Readable by what? Notepad.exe? Excel? MS Word? Other? It makes a big > > difference which application you use! > Sorry about that . Its a *.txt file: > > Here's a sample of my output: > ------------------------------------------ > 4711-10077 CR0102 1 03 > 083100015 C2 1 05 > 4711-10077 C7,CR101,CR102 3 02 > 4711-10077 CR103,CR104 2 02 > 4711-10077 CR105 1 02 > 4711-10077 C11 1 01 > 4711-10077 C3 1 02 > 083100015 C3 1 0139271529 > > What I would like to see is as follows (ie the columns are aligned in > the .txt file) > ---------------------------------------------------------------------------*----------------------- > 4711-10077 CR0102 1 03 > 083100015 * * * * * * * * C2 1 05 > 4711-10077 C7,CR101,CR102 3 02 > 4711-10077 CR103,CR104 2 02 > 4711-10077 CR105 1 02 > 4711-10077 C11 1 01 > 4711-10077 C3 1 02 > 083100015 * * C3 1 0139271529 > > ====================== > > If you want your columns neatly aligned in a text file using a fixed pitch > character set then you should use spaces to pad them out rather than tabs.. > Instead of coding > > objFile.Writeline PN & vbTAB & refdes & vbTAB & qty & vbTAB & load & vbCR > > you might code like so: > > objFile.Writeline pad(PN) & pad(refdes) & pad(qty) & pad(load) > > Function pad (sWord) > *If Len(sWord) >= 10 Then > * pad = sWord > *Else > * pad = sWord & Space(10 - Len(sWord)) > *End If > End Function- Hide quoted text - > > - Show quoted text - |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Appending to an XML file | VB Script | |||
| Writing File to CD ROM | VB Script | |||
| writing out to file | PowerShell | |||
| writing output to XML file | PowerShell | |||
| Writing to a file with out-file or export-csv | PowerShell | |||