'********************************************************************************************************** ' Name: cutChars ' Author: mielk | 2013-05-15 ' ' Comment: Function cuts the specified number of characters at the end of the source string. ' ' Parameters: ' text String to be shortened. ' chars Number of characters to be cutted. It should be positive number. ' If this argument is 0 or negative number, the original string is returned without ' any changes. ' ' Returns: ' String The original string without the specified number of characters at the end of this ' string. ' ' Example: ' ?cutChars("String", 3) = "Str" <--- 3 characters have been cut from the original ' string "String") ' ' ' --- Changes log ----------------------------------------------------------------------------------------- ' 2013-05-15 mielk Method created. '********************************************************************************************************** Public Function cutChars(text As String, chars As Integer) As String Const METHOD_NAME As String = "cutChars" '------------------------------------------------------------------------------------------------------ 'Check if the number of characters to be cutted is not greater than the length of the base string. 'If it is, return empty String. If chars > VBA.Len(text) Then cutChars = "" Else cutChars = VBA.Left$(text, VBA.Len(text) - chars) End If End Function