473,396 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

String with double quotes

I have a label control on my form. I'm assigning a text to the label at
runtime.
The problem is that the string that I'm trying to assign also contains text
in double quotes.So when I try n assign this to the label I face a problem.
my code is using vb.net

Please help me out in getting this thing done, Is there any in-built
function or property to handle the same?

thanx
Ganesh
Nov 19 '05 #1
5 1947
Are you getting any specific error messages?

You may need to encode your string using System.Web.HttpUtilites.HtmlEncode,
before putting it into your label.

Mun

--
Munsifali Rashid
http://www.munit.co.uk/blog/
"Ganesh" <Ga****@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
I have a label control on my form. I'm assigning a text to the label at
runtime.
The problem is that the string that I'm trying to assign also contains
text
in double quotes.So when I try n assign this to the label I face a
problem.
my code is using vb.net

Please help me out in getting this thing done, Is there any in-built
function or property to handle the same?

thanx
Ganesh

Nov 19 '05 #2
All you need to do is use "double double" quotes (a term I just made up):

For example:

lblMain.text = """Hello World """

will show on your screen as:

"Hello World"

lblMain.text = """" + "Hello World" + """"

will produce the same result!

Hope this helps you!

Fred

"Ganesh" <Ga****@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
I have a label control on my form. I'm assigning a text to the label at
runtime.
The problem is that the string that I'm trying to assign also contains text in double quotes.So when I try n assign this to the label I face a problem. my code is using vb.net

Please help me out in getting this thing done, Is there any in-built
function or property to handle the same?

thanx
Ganesh

Nov 19 '05 #3
Your best bet would probably be to HTML-encode the string. e.g.:

someLabel.Text = Server.HtmlEncode(yourString)

This will replace the quotes with &quot; named entity, as well as escaping
other HTML that might potentially cause problems (e.g.: unexpected page
modifications or cross-site scripting).

"Ganesh" <Ga****@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
I have a label control on my form. I'm assigning a text to the label at
runtime.
The problem is that the string that I'm trying to assign also contains
text
in double quotes.So when I try n assign this to the label I face a
problem.
my code is using vb.net

Please help me out in getting this thing done, Is there any in-built
function or property to handle the same?

thanx
Ganesh

Nov 19 '05 #4
No I don't get any specific error message.
The problem is that I'm reading this from a source where the text contains
phrases that are mentioned in double quotes.
So i dont know how do I handle this.
"Munsifali Rashid" wrote:
Are you getting any specific error messages?

You may need to encode your string using System.Web.HttpUtilites.HtmlEncode,
before putting it into your label.

Mun

--
Munsifali Rashid
http://www.munit.co.uk/blog/
"Ganesh" <Ga****@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
I have a label control on my form. I'm assigning a text to the label at
runtime.
The problem is that the string that I'm trying to assign also contains
text
in double quotes.So when I try n assign this to the label I face a
problem.
my code is using vb.net

Please help me out in getting this thing done, Is there any in-built
function or property to handle the same?

thanx
Ganesh


Nov 19 '05 #5
Hi Ganesh,

There are two ways to have double quote sign in string:

1) Dim strQuote As String = "text""" ' It shows text"

2) Dim strQuote As String = "text" & Chr(34) ' It also
shows text"

HTH

Elton Wang
el********@hotmail.com

-----Original Message-----
I have a label control on my form. I'm assigning a text to the label atruntime.
The problem is that the string that I'm trying to assign also contains textin double quotes.So when I try n assign this to the label I face a problem.my code is using vb.net

Please help me out in getting this thing done, Is there any in-builtfunction or property to handle the same?

thanx
Ganesh
.

Nov 19 '05 #6

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

Similar topics

9
by: PaulThomas | last post by:
I want to "look" through a comma delimited String and "take it apart" by finding the comma's and then put each "set of characters" into seperate strings - - - maybe an array, maybe seperate cells...
3
by: Stefania Scott | last post by:
How do I resolve the problem of passing a string that has quotes within in a SQL statement? Sometimes the string contains a single quote (') and some others it contains the double quote (")? Any...
5
by: Ann Marinas | last post by:
Happy New Year to all! :D I am currently developoing an application that imports data from a CSV file. Each comma represents an array item that I need to extract data with. My problem is...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
1
by: Mark Rae | last post by:
Hi folks, Apologies - am having a bit of a "senior moment"... Is there a way to convert a string containing escaped characters into a verbatim string literal? I.e. converting something like...
16
by: Charles Law | last post by:
I have a string similar to the following: " MyString 40 "Hello world" all " It contains white space that may be spaces or tabs, or a combination, and I want to produce an array...
8
by: Ian Davies | last post by:
Hello I have the following sql string to run as a command in my VB6 project to update mysql table strSQL = "LOAD DATA INFILE " & ImportFile & " INTO TABLE tPupils FIELDS TERMINATED BY ','...
5
by: geotso | last post by:
Here is the scenario: 1. I have a table (tblCalendar) with the following fields: caldID caldDate caldTitle caldInfo nWinW nWinH
9
by: a | last post by:
I need to write a regular expression to match a quoted string in which the double quote character itself is represented by 2 double quotes. For example: "beginning ""nested quoted string"" end"...
4
by: Michael Yanowitz | last post by:
Hello: If I have a long string (such as a Python file). I search for a sub-string in that string and find it. Is there a way to determine if that found sub-string is inside single-quotes or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.