May 18

Truncate a String to a Specific Length Function (trunkString)

Truncates a string to a given length and adds a "…" at the end. If the string is not truncated (shorter than max) returns the same string that was sent.

function trunkString(strIn,intLength)
	if len(strIn) <= intLength then
		trunkString = strIn 
	else
		trunkString = left(strIn,(intLength-3)) & "..."
	end if
end function

Permanent link to this article: https://www.wperry.net/code/trunkstring/

Leave a Reply

Your email address will not be published.