FF_CLIPLEFT, FF_CLIPRIGHT, FF_CLIPMID

Started by Paul Squires, August 19, 2015, 01:46:55 PM

Previous topic - Next topic

Paul Squires




''
''  FF_CLIPLEFT
''  Returns a string with nCount characters removed from the left side of the string.
''
''  If nCount is less than one then the entire string is returned.
''
Function FF_ClipLeft( ByRef sMainString As String, _
                      ByRef nCount      As Integer _
                      ) As String

    Dim nLen As Integer = Len(sMainString)
    If nCount <= 0 Then Return sMainString
   
    nCount = Iif(nLen < nCount, nLen, nCount)
    Function = Mid(sMainString, nCount+1)
   
End Function


''
''  FF_CLIPRIGHT
''  Returns a string with nCount characters removed from the right side of the string.
''
''  If nCount is less than one then the entire string is returned.
''
Function FF_ClipRight( ByRef sMainString As String, _
                       ByRef nCount      As Integer _
                       ) As String

    Dim nLen As Integer = Len(sMainString)
    If nCount <= 0 Then Return sMainString
   
    nCount = nLen - nCount
    nCount = Iif(nLen < nCount, nLen, nCount)
    Function = Left(sMainString, nCount)
   
End Function


''
''  FF_CLIPMID
''  Returns a string with nCount characters removed starting at position
''  nStart. The first character is considered position 1, the second
''  position 2, etc...
''
''  If nCount or nStart is less than one then the entire string is returned.
''
Function FF_ClipMid( ByRef sMainString As String, _
                     ByRef nStart      As Integer, _
                     ByRef nCount      As Integer _
                     ) As String

    Dim nLen As Integer = Len(sMainString)
    If (nCount <= 0) Or (nStart <= 0) Then Return sMainString
   
    Function = Left(sMainString, nStart - 1) & Mid(sMainString, nStart + nCount)
   
End Function

Paul Squires
PlanetSquires Software