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 - Chomp Echo String; No New Line Please!

Reply
 
Old 08-22-2008   #1 (permalink)
Todd Walton


 
 

Chomp Echo String; No New Line Please!

When I do this:

WScript.Echo (strEighthLine & ipAddress)

I get a string of text on one line, and then an IP address on the next
line. How can I print this so that there's *not* a newline in
between? I want my text, and then the IP address all on the same
line.

-todd

My System SpecsSystem Spec
Old 08-22-2008   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Chomp Echo String; No New Line Please!

Todd wrote:
Quote:

> When I do this:
>
> WScript.Echo (strEighthLine & ipAddress)
>
> I get a string of text on one line, and then an IP address on the next
> line. How can I print this so that there's *not* a newline in
> between? I want my text, and then the IP address all on the same
> line.
The value assigned to the variable strEighthLine must include a trailing
NewLine (vbCrLf). For example, if you code:
=========
Wscript.Echo strEighthLine
Wscript.Echo strEighthLine
=======
There will be a blank line separating the two lines. If you cannot fix the
code that assigns a value to strEighthLine, maybe you can strip off the last
2 characters. For example:

strEightLine = Left(strEightLine, Len(strEighthLine) - 2)

This assumes there are actually two trailing characters, the Carriage Return
and the Line Feed.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 08-23-2008   #3 (permalink)
Todd Vargo


 
 

Re: Chomp Echo String; No New Line Please!

Richard Mueller wrote:
Quote:

> Todd wrote:
>
Quote:

> > When I do this:
> >
> > WScript.Echo (strEighthLine & ipAddress)
> >
> > I get a string of text on one line, and then an IP address on the next
> > line. How can I print this so that there's *not* a newline in
> > between? I want my text, and then the IP address all on the same
> > line.
>
> The value assigned to the variable strEighthLine must include a trailing
> NewLine (vbCrLf). For example, if you code:
> =========
> Wscript.Echo strEighthLine
> Wscript.Echo strEighthLine
> =======
> There will be a blank line separating the two lines. If you cannot fix the
> code that assigns a value to strEighthLine, maybe you can strip off the
last
Quote:

> 2 characters. For example:
>
> strEightLine = Left(strEightLine, Len(strEighthLine) - 2)
>
> This assumes there are actually two trailing characters, the Carriage
Return
Quote:

> and the Line Feed.
It is possible to have a CR without a LF, as well as it may be at the
beginning of the latter variable. The following removes them regardless of
location.

tmp = strEighthLine & ipAddress
tmp = Replace(tmp, Chr(13), "")
tmp = Replace(tmp, Chr(10), "")
WScript.Echo tmp

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Old 08-24-2008   #4 (permalink)
Todd Walton


 
 

Re: Chomp Echo String; No New Line Please!

Beautiful. Thanks Richard. Thanks Todd.

-todd
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
wscript.echo only a new line / embed a "CR" in a text string ? VB Script
Need full line of text from select-string PowerShell
Write every line except the one with first occurence of a string PowerShell
Search for string in CSV and delete line if string found in line PowerShell
Getting the next line after a string 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