473,805 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prevent 'Chr(13) + Chr(10)' from Being Executed in String

I have the following code in my web page.

Dim tmpReplace As String
'Giving tmpReplace the value from the textbox on the
webform.
tmpReplace = txtComments.Tex t.Trim
'Prevents report from crashing when a single quote is in
string
tmpReplace = tmpReplace.Repl ace("'", "''")
'Replace carriage return with the appropriate CharCodes.
tmpReplace = tmpReplace.Repl ace("\n", "chr(13) + chr(10)")

I want to display the following text on my report: chr(13) + chr(10)
Instead what is happening is that .Net is executing the chr function
and creating a carriage return. What do I need to do to prevent the
chr function from being launched?
Nov 17 '05 #1
2 11401
| tmpReplace = tmpReplace.Repl ace("'", "''")
| 'Replace carriage return with the appropriate CharCodes.
| tmpReplace = tmpReplace.Repl ace("\n", "chr(13) + chr(10)")
|
| I want to display the following text on my report: chr(13) + chr(10)
| Instead what is happening is that .Net is executing the chr function
| and creating a carriage return. What do I need to do to prevent the
| chr function from being launched?

It's not executing the Chr function. "\n" is not special character i VB.NET.
If you want to replace CRLF, use:

tmpReplace = tmpReplace.Repl ace(vbCrLf, "chr(13) + chr(10)")

But if you're doing this only for storing in database, use parameters
instead and everything - quotes, line ends etc. - would be escaped
automatically.

--
Michal A. Valasek, Altair Communications, http://www.altaircom.net
Please do not reply to this e-mail, for contact see http://www.rider.cz
Nov 17 '05 #2
I removed the "\n" from the code. The example I was using to go by
said this would remove the return, but obviously it wont. Here is what
I changed it to.

Here is code from my report options page:

'Setup user's comments in correct format so that it can be
'passed to the comment formula on the report.

Dim tmpReplace As String

tmpReplace = txtComments.Tex t.Trim

'Replace double quotes in the string with 2 double quotes.
tmpReplace=tmpR eplace.Replace( Chr(34), Chr(34) + Chr(34))

'Replace carriage returns & line feed with double quotes &
'text that represents a return and line feed.
tmpReplace = tmpReplace.Repl ace(Chr(13) + Chr(10), """ +
chr(13) + chr(10) + """)

'Add double quotes to tmpReplace.
tmpReplace = """" + tmpReplace + """"

Session("UComme nts") = tmpReplace

This allows me to pass the text to my web form that contains my
CrystalReport Viewer. On this page, I have the following text:

oRpt.DataDefini tion.FormulaFie lds.Item("UserC omments").Text
= Trim(Session("U Comments"))
CrystalReportVi ewer1.ReportSou rce = oRpt

By doing this I can pass the value to a blank formula field named
UserComments on my report. Took forever, but I finally got everything
to work.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
8827
by: Eddie B. | last post by:
Does anyone know how to do Chr$(13) in .NET? Thanks, Eddie
6
91671
by: C L Humphreys | last post by:
Hi, I'm trying to concatenate address fields and insert a LF&CR after each line. The SQL I use is based on select address1 & chr(10) & chr(13)& address2 & chr(10) & chr(13)& address3 & chr(10) & chr(13)& address4 & chr(10) & chr(13)&
1
8369
by: jdph40 | last post by:
I am trying to enter text to look like paragraphs in a text box on a report, making it look like a memo. I enter (Chr$(13) & Chr$(10) & Chr$(10)) to insert a carriage return and 2 line breaks, but a small black square prints on the report. If I enter Chr$(10) once, the square doesn't print. Can you only have one line break? TIA, JD
2
18136
by: lauren quantrell | last post by:
Has anyone cunstructed a function to remove multiple carriage returns and replace it with a single return? Replace(mytext, Chr(13) & Chr(10) & Chr(13) & Chr(10), Chr(13) & Chr(10)) ... only works to remove double carriage returns. Thanks. lq
2
3852
by: MLH | last post by:
I run the following command in main menu form open event code... Me!MainMenuLabel.Caption = DLookup("", "qryAdminList") & Chr$(10) & Chr$(13) & DLookup("", "qryAdminList") & Chr$(10) & Chr$(13) & DLookup("", "qryAdminList") The caption on the label is not what I want at all. All 3 dlookups return valid strings. Its the carriage returns and line feeds. They are showing as literal characters instead of doing what I'd hoped for.
10
17769
by: Dan Nash | last post by:
Lo, In a previous version of an app, I used replace to convert multiline text boxes to something easier to put in a database, and then i used replace(chr(13), "<br>") when i needed to show the data. I'm now working on a new version of this app, and im using C# / .NET. Obviously I'm using the old database, but I cant find out how to do replace(chr(13), "<br>").
1
2245
by: Felix | last post by:
We have a problem with the Chr(13) and WebServices (we are using VB.NET 2003). If we have a string that contains the Chr(13) and the Chr(10) (just the vbCrLf characters) and we pass it through a web service call, then the web service recieves the string without the Chr(13). It seems that the Web Service "eats" all Chr(13) out of all the characters of the string. It also happens when the WebService returns a string with this character. How...
5
7747
by: Computer Guru | last post by:
I have a form I'm using as a dialog box. It has default text that is two paragraphs. It has a function setText(byval text as string) that specifies the text in the read-only textbox that's on it. For some odd reason, dialog1.setText("Line 1" & chr(13) & chr(13) & "Line 2") shows up as "Line 1Line 2" on Vista, and as "Line 1Line2" on 2k3, where is an
4
5206
by: ebasshead | last post by:
Hi Everybody, I'm trying to figure out what the opposite of Chr$(10)... "line feed" is, does one exist? Cheers Eddie
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10609
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9185
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7646
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.