Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

use Replace &

I can use replace all in one line, but I can be very long. How can I use "&" to go to the next line


dim test as string = "Bofa, Citibank, Chase"
dim test2 as string = test.replace("bofa", "Bank of American").replace("Citibank", Citi Bank) & 
replace...etc

to
something like this...

dim test2 as string = test.replace("bofa", "Bank of American") & _ "
                                    .replace("Citibank", Citi Bank) &  _
                                    .replace("Chase", Chase Bank) &  _
                                    etct
Avatar of HomerTNachoCheese
HomerTNachoCheese

Probably something like:
test2=test
with test2:
   .replace("bofa", "Bank of American")
   .replace("Citibank", Citi Bank)
   .replace("Chase", Chase Bank)
end with
You should probably be using the "with" keyword as previously suggested, but if you want it all on a "single line", see this link:

http://msdn.microsoft.com/en-us/library/aa711641(v=vs.71).aspx
Avatar of VBdotnet2005

ASKER

I tried With. It does not work.
ASKER CERTIFIED SOLUTION
Avatar of Anil Golamari
Anil Golamari
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dim y As String = x.Replace("bofa", "Bank Of America") _
                          .Replace("Chase", "JP Morgan Chase")
works....
Glad that helped you. (Just a space and underscore at the end of line)