473,787 Members | 2,928 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a quote as a literal

How can I use a quote as a literal so it does get confused as not a literal?

Thanks!

Bob
Jun 5 '07 #1
10 3026
On Jun 5, 9:43 am, BobAchgill <BobAchg...@dis cussions.micros oft.com>
wrote:
How can I use a quote as a literal so it does get confused as not a literal?

Thanks!

Bob
Quotes can be escaped by doubling.

Dim s as String = "<img src=""image1.jp g"">"

Jun 5 '07 #2

"BobAchgill " <Bo********@dis cussions.micros oft.comwrote in message
news:8E******** *************** ***********@mic rosoft.com...
How can I use a quote as a literal so it does get confused as not a
literal?

Thanks!

Bob
If you mean within a string, try something like this:

Label1.Text = "This displays a quotation mark = ""!"

The double quotes before the exclamation mark will display as a single
quote, part of the literal.
Jun 5 '07 #3


"pvdg42" wrote:
>
"BobAchgill " <Bo********@dis cussions.micros oft.comwrote in message
news:8E******** *************** ***********@mic rosoft.com...
How can I use a quote as a literal so it does get confused as not a
literal?

Thanks!

Bob

If you mean within a string, try something like this:

Label1.Text = "This displays a quotation mark = ""!"

The double quotes before the exclamation mark will display as a single
quote, part of the literal.
True, but ersonally I prefer to use ControlChars.Qu ote and build the string
up as I find it easier to read

guy
Jun 5 '07 #4
So what would that look like in a literal string nested with variables? Like
this??

strMyString = "I am about to have a "COW" for the " + Counter + " time!"

strMyString = "I am about to have a ControlChars.Qu ote COW
ControlChars.Qu ote for the " + Counter + " time!"

Thanks! Bob

"guy" wrote:
>

"pvdg42" wrote:

"BobAchgill " <Bo********@dis cussions.micros oft.comwrote in message
news:8E******** *************** ***********@mic rosoft.com...
How can I use a quote as a literal so it does get confused as not a
literal?
>
Thanks!
>
Bob
If you mean within a string, try something like this:

Label1.Text = "This displays a quotation mark = ""!"

The double quotes before the exclamation mark will display as a single
quote, part of the literal.

True, but ersonally I prefer to use ControlChars.Qu ote and build the string
up as I find it easier to read

guy
Jun 6 '07 #5
BobAchgill wrote:
So what would that look like in a literal string nested with variables? Like
this??

strMyString = "I am about to have a "COW" for the " + Counter + " time!"

strMyString = "I am about to have a ControlChars.Qu ote COW
ControlChars.Qu ote for the " + Counter + " time!"

Thanks! Bob
You have to put ControlChars.Qu ote outside of the string:

strMyString = "I am about to have a " & ControlChars.Qu ote & "COW" &
ControlChars.Qu ote & " for the " & Counter & " time!"

In my opinion, this is not easier to read than:

strMyString = "I am about to have a ""COW"" for the " & Counter & " time!"
--
Göran Andersson
_____
http://www.guffa.com
Jun 6 '07 #6
On Jun 6, 6:14 am, Göran Andersson <g...@guffa.com wrote:
BobAchgill wrote:
So what would that look like in a literal string nested with variables?Like
this??
strMyString = "I am about to have a "COW" for the " + Counter + " time!"
strMyString = "I am about to have a ControlChars.Qu ote COW
ControlChars.Qu ote for the " + Counter + " time!"
Thanks! Bob

You have to put ControlChars.Qu ote outside of the string:

strMyString = "I am about to have a " & ControlChars.Qu ote & "COW" &
ControlChars.Qu ote & " for the " & Counter & " time!"

In my opinion, this is not easier to read than:

strMyString = "I am about to have a ""COW"" for the " & Counter & " time!"

--
Göran Andersson
_____http://www.guffa.com
Not to mention the minor performance hit for string concatenation for
using ControlChars.Qu ote

Thanks,

Seth Rowe

Jun 6 '07 #7
rowe_newsgroups wrote:
<snip using doubled quotation marks vs. ControlChars.Qu ote>
Not to mention the minor performance hit for string concatenation for
using ControlChars.Qu ote
Surely the compiler evaluates such things at compile-time? Or is that where
you're saying the performance hit comes?
Ugh! I just put

Dim a As Integer = CInt(1 / Math.Sin(0))

and it didn't complain until run-time. So it has a limit to what it'll try
to evaluate, e.g. it does complain about

Dim a As Integer = CInt(1 / 0)

"Constant expression not representable in type Integer".

Andrew
Jun 6 '07 #8
On Jun 6, 5:59 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
On Jun 6, 6:14 am, Göran Andersson <g...@guffa.com wrote:
BobAchgill wrote:
So what would that look like in a literal string nested with variables? Like
this??
strMyString = "I am about to have a "COW" for the " + Counter + " time!"
strMyString = "I am about to have a ControlChars.Qu ote COW
ControlChars.Qu ote for the " + Counter + " time!"
Thanks! Bob
You have to put ControlChars.Qu ote outside of the string:
strMyString = "I am about to have a " & ControlChars.Qu ote & "COW" &
ControlChars.Qu ote & " for the " & Counter & " time!"
In my opinion, this is not easier to read than:
strMyString = "I am about to have a ""COW"" for the " & Counter & " time!"
--
Göran Andersson
_____http://www.guffa.com

Not to mention the minor performance hit for string concatenation for
using ControlChars.Qu ote

Thanks,

Seth Rowe
ControlChars.Qu ote is a constant so the compiler concatenates it a
compile time. Now the Counter variable, not being a constant, will
cause a concatenation at runtime, but there's not performance hit to
using ControlChars.Qu ote. I agree with Goran that using "" is easier
to read.

Chris

Jun 6 '07 #9
On 6 jun, 09:21, Chris Dunaway <dunaw...@gmail .comwrote:
On Jun 6, 5:59 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:


On Jun 6, 6:14 am, Göran Andersson <g...@guffa.com wrote:
BobAchgill wrote:
So what would that look like in a literal string nested with variables? Like
this??
strMyString = "I am about to have a "COW" for the " + Counter + "time!"
strMyString = "I am about to have a ControlChars.Qu ote COW
ControlChars.Qu ote for the " + Counter + " time!"
Thanks! Bob
You have to put ControlChars.Qu ote outside of the string:
strMyString = "I am about to have a " & ControlChars.Qu ote & "COW" &
ControlChars.Qu ote & " for the " & Counter & " time!"
In my opinion, this is not easier to read than:
strMyString = "I am about to have a ""COW"" for the " & Counter & "time!"
--
Göran Andersson
_____http://www.guffa.com
Not to mention the minor performance hit for string concatenation for
using ControlChars.Qu ote
Thanks,
Seth Rowe

ControlChars.Qu ote is a constant so the compiler concatenates it a
compile time. Now the Counter variable, not being a constant, will
cause a concatenation at runtime, but there's not performance hit to
using ControlChars.Qu ote. I agree with Goran that using "" is easier
to read.

Chris- Ocultar texto de la cita -

- Mostrar texto de la cita -
Hi Bob

You can use quotes in this way:

Dim strCad as String = "I am about to have a ""COW"" for the " +
Counter + " time!"

Just using double quotes... Do I make myself clear?

Jun 6 '07 #10

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

Similar topics

6
4758
by: Sona | last post by:
Hi, What's the advantage/disadvantage of using a "const char*" over a "char*" ? I read some place that char* are string literals that on some machines are stored in a read only memory and cannot be modified... does that apply on const char*? thanks Sona
0
1958
by: peridian | last post by:
Hi, I wanted a web page where I could post code to, and have it appear in coloured formatting based on the context of the code. Most of the techniques I have seen for this involve complex use of string manipulation where they seek through the string back and forth doing replacements to substitute in the needed HTML code. I am convinced that this can be done with a few regular expressions. Unfortunately my knowledge of regular...
5
4805
by: RC- | last post by:
Hi everyone, I have been searching and searching for an answer to this question using Google and what not; I have not been able to find a "clear cut" answer. OK, now the question: I have a Repeater control that works great. What I am trying to do is perform an active count of the number of rows that the repeater is rendering. The end goal is to insert a page break after six rows of data. I cannot figure out how to count the rows one...
6
1401
by: anton | last post by:
Hi, I want to replace all occourences of " by \" in a string. But I want to leave all occourences of \" as they are. The following should happen: this I want " while I dont want this \"
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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
8993
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
7517
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
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.