use Replace  &

VBdotnet2005
VBdotnet2005 used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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

Author

Commented:
I tried With. It does not work.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Dim x As String = Textbox1.Text
        Dim y As String = x.Replace("bofa", "Bank Of America") _
                          .Replace("Chase", "JP Morgan Chase")

this should work

Author

Commented:
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)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial