Avatar of VBdotnet2005
VBdotnet2005
Flag 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
Visual Basic.NET

Avatar of undefined
Last Comment
Anil Golamari

8/22/2022 - Mon
HomerTNachoCheese

Probably something like:
test2=test
with test2:
   .replace("bofa", "Bank of American")
   .replace("Citibank", Citi Bank)
   .replace("Chase", Chase Bank)
end with
mwheeler1982

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
VBdotnet2005

ASKER
I tried With. It does not work.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Anil Golamari

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
VBdotnet2005

ASKER
Dim y As String = x.Replace("bofa", "Bank Of America") _
                          .Replace("Chase", "JP Morgan Chase")
works....
Anil Golamari

Glad that helped you. (Just a space and underscore at the end of line)