'********************************************************************

'* Function RTrimText

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2004-11-12

'* Modified: 2008-12-06

'*

'* Purpose: Returns a string with the text removed from Right side of String.

'*

'*   Input: strTrim = A string to have the Text Removed.

'*        strRemove = The string to remove from the Right side of the strTrim

'*          blnCase = A boolean indicating case sensitive searches

'*                      True  = Case Sensitive Search

'*                      False = Case Insensitive Search

'*

'*  Output: Returns a string with the text removed from Right side of String.

'*          Returns strTrim if strRemove or strTrim is Empty or = ""

'*

'*   Notes: Case In-Sensitive comparison is used.

'*

'* Changes:

'* 2007-01-07: Added ByVal to the parameter list

'* 2008-12-06: Added blnCase removed hard coded vbTextCompare and use

'*               ReturnCaseComparisonValue instead.

'********************************************************************

Function RTrimText(ByVal strTrim, ByVal strRemove, ByVal blnCase)

  'Version: 1.3 2008-12-06

  Dim intLenRemove, intLenTrim, strTemp, strOut, intSearch

 

  intSearch = ReturnCaseComparisonValue(blnCase)

 

  intLenRemove = Len(strRemove)

  intLenTrim = Len(strTrim)

 

  If (intLenRemove = 0) Or (IsEmpty(strRemove)) Then

    RTrimText = strTrim

    Exit Function

  End If

 

  If (intLenTrim = 0) Or (IsEmpty(intLenTrim)) Then

    RTrimText = strTrim

    Exit Function

  End If

  

  If intLenTrim  >= intLenRemove Then

    strTemp = Right(strRemove, intLenTrim)

    If InStr(1, strTemp, strRemove, intSearch) = 1 Then

      strOut = Mid(strTrim, 1, intLenTrim - intLenRemove)

    Else

      strOut = strTrim

    End If 'InStr(1, strTemp, strTrim, intSearch) = 1

  Else

    strOut = strTrim

  End If 'intLenTrim  >= intLenRemove

  RTrimText = strOut

End Function 'RTrimText

Article ID: 419, Created On: 9/25/2011, Modified: 9/25/2011