从数据库取数据时,带有回车/换行符替换方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/I_Order/article/details/60879115
    Public Shared Function delEnterCharForPrint2(ByVal 
    strValue As String) As String
        Dim strReturn As String = strValue
        '单引号(因为后面会加入单引号,所以必须先替换单引号)
        strReturn = strReturn.Replace(Chr(39).ToString, "'+ String.fromCharCode(39) +'")
        '替换回车符
        strReturn = strReturn.Replace(Chr(10).ToString, "'+ String.fromCharCode(10) +'")
        strReturn = strReturn.Replace(Chr(13).ToString, "'+ String.fromCharCode(13) +'")
        strReturn = strReturn.Replace(Chr(92).ToString, "'+ String.fromCharCode(92) +'")
        Return strReturn
    End Function

猜你喜欢

转载自blog.csdn.net/I_Order/article/details/60879115