Add chr in string

moishy

Registered User.
Local time
Today, 15:53
Joined
Dec 14, 2009
Messages
264
Hello to All,

How can I add a double-quotation mark (") before the last chr in a string?
 
This should work:

ReturnValue=Mid([FieldName],1,Len([FieldName])-1) & '"' & Mid([FieldName],Len([FieldName]),1)
 
So I tried this
Code:
 r$ = Mid(r$, 1, Len(r$) - 1) & '"' & Mid(r$,Len(r$),1)"
and I got a Compile Error: Expected Expression
 
Hi -

Try this (example from the debug/immediate window):

x = "the quick brown fox"
? Mid(x,1,Len(x)-1) & """" & Mid(x,Len(x),1)
the quick brown fo"x

-or-

? Mid(x,1,Len(x)-1) & chr(34) & Mid(x,Len(x),1)
the quick brown fo"x

HTH - Bob
 
Chr(34) is a double quotes.
Code:
YourString="Some string" & chr(34)
 
raskew,

This is the only way it works, putting in the string wrapped id double quotation marks.
Code:
? Mid("the quick brown fox",1,Len("the quick brown fox")-1) & chr(34) & Mid("the quick brown fox",Len("the quick brown fox"),1)
But if I try this it doesn't work
Code:
? Mid(r$,1,Len(r$)-1) & chr(34) & Mid(r$,Len(r$),1)
r$ holds a value of "the quick brown fox".
 
i ytend to use the method jack outlined in #5

use chr(34). it is much easier than getting the right syntax for wrapping the actual quote character

this sort of thing

newstrg = leftstrg(string, 12) & chr(34) & mid(string,13)
 
Don't be using $ in your variables. It is an old, outdated way of doing it, which can cause issues now days.
 

Users who are viewing this thread

Back
Top Bottom