AddRightIfDoesntExist

        ''' <summary>
        ''' Adds a value onto the end of the string if it does not already exist there.
        ''' </summary>
        ''' <param name="buf"></param>
        ''' <param name="value"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <Extension()> _
        Public Function AddRightIfDoesntExist(ByVal buf As String, ByVal value As String) As String
            If buf.Length < value.Length Then
                Return buf
            End If

            If buf.Right(value.Length) = value Then
                Return buf
            Else
                Return buf & value
            End If
        End Function
Example:
Dim buf As String = CurDir.AddRightIfDoesntExist("\")
MsgBox(buf)

Description

Adds a value onto the end of the string if it does not already exist there.

Details

Double click on the code to select all.

 

;