Sign in to follow this  

What is VB.NET's newline keyword?

Recommended Posts

Actually, if you want C style escape characters:

'simple iterative string processor to convert C style escape sequences (written by Promit Roy)
Public Function EscapeString( Text As String ) As String
Dim Res As String
Dim Arr As Char()
Dim i As Integer

Arr = Text.ToCharArray()

i = 0
Do While i < Arr.Length()
If Arr(i) = "\" Then
'process it
i += 1
Select Case Arr(i)
Case "t"
Res += vbTab
Case "r"
Res += vbCr
Case "n"
Res += vbLf
Case "v"
Res += vbVerticalTab
Case "f"
Res += vbFormFeed
Case "'"
Res += "'"
Case """" 'double quote
Res += """"
Case "b"
Res += vbBack
Case "0"
Res += vbNullChar
Case "a"
Res += Chr( &H7 )
Case "\"
Res += "\"
Case Else
'don't do anything with res
End Select
Res += Arr(i)
End If

i += 1

Return Res
End Function

It's not nearly as powerful as the actual C escape sequences, but provides most of the common escape characters.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this