Discussion:
Chomp Echo String; No New Line Please!
(too old to reply)
Todd Walton
2008-08-22 22:03:11 UTC
Permalink
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
Richard Mueller [MVP]
2008-08-22 22:21:06 UTC
Permalink
Post by Todd Walton
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
--
Todd Vargo
2008-08-23 05:16:26 UTC
Permalink
Post by Richard Mueller [MVP]
Post by Todd Walton
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
=========
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
strEightLine = Left(strEightLine, Len(strEighthLine) - 2)
This assumes there are actually two trailing characters, the Carriage Return
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)
Todd Walton
2008-08-24 12:58:36 UTC
Permalink
Beautiful. Thanks Richard. Thanks Todd.

-todd

Continue reading on narkive:
Search results for 'Chomp Echo String; No New Line Please!' (Questions and Answers)
78
replies
Please, EVERYONE ANSWER THIS QUESTION...?
started 2006-09-12 11:22:32 UTC
games & recreation
Loading...