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

Replace Function ASP.NET

Status
Not open for further replies.

Naoise

Programmer
Dec 23, 2004
318
IE
Try this in legacy ASP
ASP
Dim x
x=""
Response.write(TypeName(x))
x=Replace(x,";","")
Response.write(TypeName(x))

...and you will still have an empty string

Try it in ASP.NET
ASP.NET
Dim x As String
x = ""
Response.Write(TypeName(x))
x = Replace(x, ";", "")
Response.Write(TypeName(x))

...and you will see that it has gone from a String to type Nothing.

How is this?
 
That is because you are specifically setting x to Nothing in your ASP.NET example with this line:
Code:
x = Replace(x, ";", "")
Instead, that line should be replaced with:
Code:
x = x.Replace(";", "")
which will perform the Replace command actually on the String itself and therefore the type will remain the same.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 

Ah fer f**k sake. Back to bed. Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top