Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - appending/writing to a file

Reply
 
Old 11-18-2008   #1 (permalink)
sa


 
 

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 SpecsSystem Spec
Old 11-18-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

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
Readable by what? Notepad.exe? Excel? MS Word? Other? It makes a big
difference which application you use!


My System SpecsSystem Spec
Old 11-18-2008   #3 (permalink)
sa


 
 

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!
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



My System SpecsSystem Spec
Old 11-18-2008   #4 (permalink)
sa


 
 

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 SpecsSystem Spec
Old 11-18-2008   #5 (permalink)
Pegasus \(MVP\)


 
 

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!
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


My System SpecsSystem Spec
Old 11-18-2008   #6 (permalink)
sa


 
 

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 -
Thnk you for you help! This should work Perfectly well!
My System SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46