Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for quote marks and other characters 1

Status
Not open for further replies.

yumbelie

Programmer
Dec 31, 2002
96
GB
Hi,

Any chance someone could tell me how I look for quote marks in a string - the obvious problem I'm having is that if you do Replace(MyString,""","0") Then it won't accept it, because it believes "" is one set of quotes, and the third is the opening of another string. What do I have to enter to be able to search a string for characters such as "

Many Thanks

yum.
 
Or double up the quotes i.e. use """" instead of """ but tends to get difficult to read.
 
For the ASCII values of other characters see:

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
I find """" to be unusual enough looking that I spot it for what it is right off.

Since excessive string concatentation is one of the biggest causes of VB slowdowns, I avoid things like

[tt]Chr$(34) & "Fred" & Chr$(34)[/tt]

... in favor of:

[tt]"""Fred"""[/tt]

... every time.

Now that I think about it though, there's no reason the VB compiler couldn't optimize the difference away. I wonder why I've never checked?
 
Just checked.

Nope, no optimization. It actually grinds away at runtime.
 
I think you may have some other problem, try putting in a few breakpoints and see what is happening.

With respect to an empty string, some very smart person some time ago suggested placing a
Public Const EmptyString As String = ""
line in a global location and then referencing that constant.

Therefore, rather than this line
StrItemxxx = ""
use
StrItemxxx = EmptyString

Anyway, just a thought, because it certainly reduces the size of the executable.

"Life is full of learning, and then there is wisdom"
 
have you already tried Glasgow's solution like this:
Code:
MyString=Replace(MyString,chr(34),"0")

Note: You need to assign the "replace" to a strings variable (myString=Replace(..).
You cannot use Replace as standalone...

Hope this helps,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
andreas.galambos@bowneglobal.de
HP:
 
Many thanks for all the assistance. So simple when you think about it. Thanks alot to all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top