Hi,
I'm trying to run this code :
strFileContentsHTML.Replace(vbLf, "<br>")
strFileContentsHTML.Replace(vbCrLf, "<br>")
strFileContentsHTML.Replace(vbCr, "<br>")
It doesn't replace newline characters with <br>.
Does anyone know how I should do this?
Thanks,
Guy 8 15692
"Guy" <Gu*@discussions.microsoft.com> schrieb: I'm trying to run this code :
strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>")
It doesn't replace newline characters with <br>.
'StringBuilder.Replace' /returns/ a reference to a string builder which
contains the final data:
\\\
strFileContentsHtml = strFileContentsHtml.Replace(...)
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thanks for the repsonse Herfried.
I tried your suggestion and it still doesn work.
I changed the code to :
strFileContentsHTML = strFileContentsHTML.Replace(vbLf, "<br>")
strFileContentsHTML = strFileContentsHTML.Replace(vbCrLf, "<br>")
strFileContentsHTML = strFileContentsHTML.Replace(vbCr, "<br>")
Earlier I tested
strFileContentsHTML.Replace("a", "<br>")
and it worked fine. The problem seems to be only with the newline characters.
Guy
"Herfried K. Wagner [MVP]" wrote: "Guy" <Gu*@discussions.microsoft.com> schrieb: I'm trying to run this code :
strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>")
It doesn't replace newline characters with <br>.
'StringBuilder.Replace' /returns/ a reference to a string builder which contains the final data:
\\\ strFileContentsHtml = strFileContentsHtml.Replace(...) ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Guy,
Strange, this test
\\\
Dim strFileContentsHTML As New System.Text.StringBuilder("Hello" & vbLf & _
"how" & vbCrLf & "are" & vbCr & "you")
strFileContentsHTML = strFileContentsHTML.Replace(vbLf, "<br>")
strFileContentsHTML = strFileContentsHTML.Replace(vbCrLf, "<br>")
strFileContentsHTML = strFileContentsHTML.Replace(vbCr, "<br>")
Debug.WriteLine(strFileContentsHTML.ToString)
///
Has for me as result.
Hello<br>how<br><br>are<br>you
Be aware that the vbcrlf is of course already done first by the vblf and
will not be done in this way so that has actualy to be done first.
I hope this helps,
Cor
Have you tried using the asci decimal value 
 or Chr(10) or Chr(13) instead of vbLf
and vbCrLf
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed..................
...............................with a computer
"Guy" <Gu*@discussions.microsoft.com> wrote in message
news:8F**********************************@microsof t.com... Thanks for the repsonse Herfried. I tried your suggestion and it still doesn work.
I changed the code to :
strFileContentsHTML = strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML = strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML = strFileContentsHTML.Replace(vbCr, "<br>")
Earlier I tested
strFileContentsHTML.Replace("a", "<br>")
and it worked fine. The problem seems to be only with the newline characters.
Guy "Herfried K. Wagner [MVP]" wrote:
"Guy" <Gu*@discussions.microsoft.com> schrieb: I'm trying to run this code :
strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML.Replace(vbCr, "<br>")
It doesn't replace newline characters with <br>.
'StringBuilder.Replace' /returns/ a reference to a string builder which contains the final data:
\\\ strFileContentsHtml = strFileContentsHtml.Replace(...) ///
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
"Guy" <Gu*@discussions.microsoft.com> schrieb: I tried your suggestion and it still doesn work.
I changed the code to :
strFileContentsHTML = strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML = strFileContentsHTML.Replace(vbCrLf, "<br>")
The order of your replacements doesn't make much sense. If you are already
replacing 'vbLf' characters with "<br>", the text doesn't contain 'vbCrLf'
character sequences any more. Are you sure the stringbuilder contains the
characters you want to replace?
Earlier I tested
strFileContentsHTML.Replace("a", "<br>")
This line won't work too because you never assign the return value of
'Replace' to a string variable.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Thanks for the response Cor.
That example works for me too.
I think I've found the problem.
I'm populating the string builder w/ :
InputStream.ReadLine
I assumed this returned everything upto and including endline characters but
apparently it only returns upto and not including the endline characters.
If I manually add my own "<br>" I get the result I'm looking for.
Guy
"Cor Ligthert" wrote: Guy,
Strange, this test \\\ Dim strFileContentsHTML As New System.Text.StringBuilder("Hello" & vbLf & _ "how" & vbCrLf & "are" & vbCr & "you") strFileContentsHTML = strFileContentsHTML.Replace(vbLf, "<br>") strFileContentsHTML = strFileContentsHTML.Replace(vbCrLf, "<br>") strFileContentsHTML = strFileContentsHTML.Replace(vbCr, "<br>") Debug.WriteLine(strFileContentsHTML.ToString) /// Has for me as result. Hello<br>how<br><br>are<br>you
Be aware that the vbcrlf is of course already done first by the vblf and will not be done in this way so that has actualy to be done first.
I hope this helps,
Cor
Herfried,
| 'StringBuilder.Replace' /returns/ a reference to a string builder which
| contains the final data:
Correct!
However! it also modifies the StringBuilder itself, and then returns a
reference to "Me".
Making the assignment:
| strFileContentsHtml = strFileContentsHtml.Replace(...)
unnecessary with StringBuilder as it is returning "Me", which has already
been modified. Unlike String.Replace that returns a new string.
The StringBuilder returns a reference to allow:
strFileContentsHTML.Replace(vbLf, "<br>").Replace(vbCrLf,
"<br>").Replace(vbCr, "<br>")
More commonly I've seen:
strFileContentsHTML.Append("Hello
").Append(firstName).Append(ControlChars.NewLi ne)
Which allows each "line" to be on a single source line, however I find it
more confusing then simply using a With statement or the original code.
Which enables C# to use:
strFileContentsHTML.Append("Hello ")
.Append(firstName)
.Append(ControlChars.NewLine);
Which VB.NET does not allow
strFileContentsHTML.Append("Hello ") _
.Append(firstName) _
.Append(ControlChars.NewLine)
However VB.NET has the With statement to cover the above, which IMHO is
better as it doesn't require the type's methods to return the "Me/this"
reference...
Hope this helps
Jay
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eO**************@TK2MSFTNGP12.phx.gbl...
| "Guy" <Gu*@discussions.microsoft.com> schrieb:
| > I'm trying to run this code :
| >
| > strFileContentsHTML.Replace(vbLf, "<br>")
| > strFileContentsHTML.Replace(vbCrLf, "<br>")
| > strFileContentsHTML.Replace(vbCr, "<br>")
| >
| > It doesn't replace newline characters with <br>.
|
| 'StringBuilder.Replace' /returns/ a reference to a string builder which
| contains the final data:
|
| \\\
| strFileContentsHtml = strFileContentsHtml.Replace(...)
| ///
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
Jay,
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schrieb: | 'StringBuilder.Replace' /returns/ a reference to a string builder which | contains the final data: Correct!
However! it also modifies the StringBuilder itself, and then returns a reference to "Me".
Thank you for making me aware of that. When I was pressing the "Send"
button I was almost sure that I missed something because I could not believe
that a new 'StringBuilder' is created when performing a simple replace
operation :-/.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hemanth |
last post by:
Hello there,
I'm new to PHP. I'm trying to run a simple php
script (on a Red hat linux machine with apache web server )
through a windows web browser (IE).
I'm using an exec() function in my...
|
by: Thomas |
last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else
has the same problem. I am using newest service package of IE and
Win2K.
Thanks
|
by: Gary Mayor |
last post by:
Hi,
If I have the ' character within the javascript:pick command it doesn't
work. Is there some sort of way of escaping these characters like in
server side languages.
function pick(symbol) {...
|
by: nick |
last post by:
I have the following code:
var ocevent = function(v)
{
alert('u clicked '+v);
return false;
};
var items = {
"002.jpg": {text:"002", href:"#", click:function(){return
|
by: Jan Bares |
last post by:
Hi,
I have .NET 2003. When I run "Find in Files" command, everything works as
expected. However when I run "Replace in Files" with the same settings a and
press Find Next, I get: "Look in: A...
|
by: Larry Woods |
last post by:
I am trying to name my submenus (MainMenu control) and they show up in the
menu dropdown...like they are O.K., but when I check my controls the names
are still "MenuItemX". OTOH, the top-level...
|
by: Barry Kelly |
last post by:
I'm running this version of Python:
Python 2.4.3 (#1, May 18 2006, 07:40:45)
on cygwin
I read in the documentation that these two expressions are
interchangeable:
...
|
by: Jake Barnes |
last post by:
I need to change imageUploadInfo2 to caption2 where the number at the
end is a variable that needs to be preserved (imageUploadInfo1 to
caption1, imageUploadInfo43 to caption43, etc)
Can anyone...
|
by: atiger |
last post by:
I am doing some validation in an ascx page. I have two textboxes. if user types char in the box, an alert box will be displayed, if user doesn't enter anything, a confirm box need to be displayed....
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: ezappsrUS |
last post by:
Hi,
I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
| | |