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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"replace" problem

Status
Not open for further replies.

MikeT

IS-IT--Management
Feb 1, 2001
376
US
I want to remove all the apostrophes from a string.
I use replace(string,"'"," ")
but I get a
"Cannot use parentheses when calling a Sub" error.

Any Ideas?
 
hmmm... I can't reproduce that problem...

Try changing the name of your string to something like myString -- maybe it is getting confused since string is a subtype of variant????

if that doesn't fix it, post the actual code snippet that's causing problems...

:)
 
Response.Write&quot;<script language=javascript>&quot;&vbcr
Response.Write&quot;aryProj = new Array();&quot;&vbcr
do while not rs.eof
strtemp=rs(&quot;field1&quot;)
replace (strtemp, &quot;'&quot;, &quot; &quot;)
Response.write&quot;aryProj[aryProj.length]='&quot;&rs(&quot;field2&quot;)&&quot;,&quot;&rs(&quot;field3&quot;)&&quot;,&quot;&temp&&quot;';&quot;&vbcr
rs.MoveNext
loop
rs.Close
response.write&quot;</script>&quot;&vbcr


The recordset is instantiated earlier. As you can see, I'm creating a js array using serverside vb. This should have nothing to do with the replace error.
 
When calling a SUB using () you need to use the call keyword..

call replace(string1,&quot;'&quot;,&quot; &quot;)

if you don't want to use call, then drop the parenthesis
replace string1, &quot;'&quot;, &quot; &quot;

 
strtemp = replace (strtemp, &quot;'&quot;, &quot; &quot;)

You have to assign the return value to something -- it's a query, not a command.

:)
 
LOL- I knew it was something stupid!
Thanks for your patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top