Friday, June 3, 2016

Remove VbCrlf Value In String From Starting Or End

Private Function RemoveVbCrlf(StrText As String) As String
    If Right$(StrText, 2) = vbCrLf Then
        RemoveVbCrlf = Left$(StrText, Len(StrText) – 2)
        StrText = Left$(StrText, Len(StrText) – 2)
    End If
   
    If Left$(StrText, 2) = vbCrLf Then
        RemoveVbCrlf = Right$(StrText, Len(StrText) – 2)
    End If
   
    If Len(RemoveVbCrlf) = 0 Then
        RemoveVbCrlf = StrText
    End If
End Function

No comments: