Question Replace error

lkrterp

Member
Joined
Jul 10, 2007
Messages
21
Programming Experience
Beginner
I am receiving the following error when trying to replace spaces with %.

"String cannot be of zero length. Parameter name: oldvalue"


Code:

Dim Keywords As String = "test abc"
Dim sqlkeywords As String

sqlkeywords = Keywords.Replace("", "%")



I have also tryed sqlkeywords = Replace(Keywords, "", "%")
and it just returns the original.... test abc.

What am I doing wrong????
 
Replace(" ","%") - can you see the space character now ? Yours was an empty string, no space.
 
Back
Top