How to use escape sequences in strings using VB.Net
Visual Basic does not support control or special or escape sequences like “\n” ( new line ) or “\t” which forces VB programmers to use constants like ControlChars.Crlf and ConrolChars.Tab. The biggest disadvantage of this is , it makes your code ugly or in technical language less readable. So this is the way we use it without escape characters
‘[ Visual Basic ]
Dim mystring as String = “Ashish Mohta ” & ControlChars.Crlf & “Phone” & ConrolChars.Tab & “Mynumber”
However there is a way to use the special characters which comes with little expense by using Regex.Unescape static method which takes a string that contains C# like escape sequences such as new line or tab.
‘[ Visual Basic ]
Dim mystring as String = Regex.Unescape(”Ashish Mohta\n Phone\tMynumber”)
I can bet that’s going to improve Vb programmers life a little bit more.
Posted on 6th April 2008 by Ashish Mohta , A Professional Tech blogger, Editor and Writer who talks about solving day to day problems of people who use computer. He also writes on How to use the applications like Office, PC tips, Online tools,Browsers and more. All posts by Ashish Mohta | Connect with me @ Twitter | Linkedin | Facebook | Stumble



Sign up for our daily email newsletter
Hello,
sir,
My name is Ankur.
I have to solve a pattern in Vb.Net.
So I need to know the Escape Sequence i.e. “\n” new line.
Please guide me…..
Leave your response!