Declare a single quote constant? (1 Viewer)

NJudson

Who farted?
Local time
Today, 16:31
Joined
Feb 14, 2002
Messages
297
I don't remember if there is a way to do this or how to do it but I'd like to declare a single quote constant but I don't know the correct syntax on how to do this. For example, if you declare a regular double quote constant it is done like this

Public Const Quote As String = """"

what I'd like to do is for a single quote like this:

Public Const Quoate As String = """

but this isn't the correct syntax and I'm not sure how to do it. Anyone have any suggestions? Thanks.
 

KenHigg

Registered User
Local time
Today, 16:31
Joined
Jun 9, 2004
Messages
13,327
Public Const Quote As String = "'"


???
kh
 

Surjer

Registered User.
Local time
Today, 21:31
Joined
Sep 17, 2001
Messages
232
Public Const Quoate As String = Chr(34)
 

NJudson

Who farted?
Local time
Today, 16:31
Joined
Feb 14, 2002
Messages
297
Ken, I'm sorry I mis-stated my question. I didn't mean a single quote. What I what is a constant or variable that is one single double quote.

I want to add double quotes around a variable but don't know how. For example, I want to turn this:

strString = Word

into this:

strString = "Word"

where word is a selected item from a list box.

I hope I stated this more clearly. Thanks for any help.
 

NJudson

Who farted?
Local time
Today, 16:31
Joined
Feb 14, 2002
Messages
297
Surjer said:
Public Const Quoate As String = Chr(34)


Surjer, I think that's what I'm looking for. Figures that it's something really simple. :rolleyes: Thanks. :)
 

Surjer

Registered User.
Local time
Today, 21:31
Joined
Sep 17, 2001
Messages
232
I have to use it in queries all the time

rs = db.openrecordset("Select * from table where field1 = " & chr(34) & mytxtVariable & chr(34)
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:31
Joined
Feb 19, 2002
Messages
43,486
Public Const Quote As String = """"
- you had it right the first time. This does store only a single double quote. Let me explain

first " = start of string
Second " = repeat character to store because it is a delimeter
Third " = character to store
Fourth " = end of string

A similar situation exists when you are creating menu items with hot keys and you want to show an ampersand (&). You need to repeat the character because the & is the character that identifies a hot key.

&Menu Item = M as the hot key

Menu &Item1 && Item2 = I as the hot key and a visible & between the two items
 
Last edited:

NJudson

Who farted?
Local time
Today, 16:31
Joined
Feb 14, 2002
Messages
297
Pat Hartman said:
- you had it right the first time. This does store only a single double quote. Let me explain

first " = start of string
Second " = repeat character to store because it is a delimeter
Third " = character to store
Fourth " = end of string


Thanks Pat, I guess it didn't look right visually when I looked at it.
 

Users who are viewing this thread

Top Bottom