Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 938
  • Last Modified:

How do I replace "&" in vb6?

hi, I know that

strFormattedString = Replace(strUnformattedString, Chr(39), "")
  GetCleanString = strFormattedString

will replace an apostrophe with a blank, but is there a # that will replace an ampersand?   My XML document is not happy with them in it...  
  Thanks in advance!

 -Al
0
afeld
Asked:
afeld
1 Solution
 
Chuckie_IceCommented:
just do this:

strFormattedString = Replace(strUnformattedString, "&" ,"")
 GetCleanString = strFormattedString
0
 
Chuckie_IceCommented:
to answer this in the way your looking for, & = 38

strFormattedString = Replace(strUnformattedString, Chr$(38), "")
GetCleanString = strFormattedString

Also, i used Chr$(38) instead of Chr(38),this may help
0
 
CareyJCommented:
'&' is an XML entity.  If you want to write it into your string you'll need to escape it like this:

strFormattedString = Replace(strUnformattedString, Chr(38), "&")

Here are some other XML entities that you might have problems in XML strings:

> = >
< = &lt;
" = &quot;
' = &apos;
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Richie_SimonettiIT OperationsCommented:
hearing...
0
 
Hornet241Commented:
I have had to do the same thing and CareyJ has the right answer.

0
 
RhaedesCommented:
At the moment your XML is just complaining about the ampersand, so you can do a replace as others have said.

If, however, there is any chance that other characters might pop up in the future (foreign names, quotation marks etc), a global solution is to replace all these 'dodgy characters' in the XML with entities (numeric or otherwise) using the free tidy.dll

http://perso.wanadoo.fr/ablavier/TidyCOM/

Rhaedes
0
 
afeldAuthor Commented:
Thanks, that is a big help!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now