Imports System.Runtime.CompilerServices Public Module StringEx ''' ''' Truncates a string to the specified length if it exceeds that length. ''' ''' The string ''' The maximum string length ''' The truncated string Public Function Truncate(pString As String, pLength As Integer) As String If String.IsNullOrEmpty(pString) Then Return pString Return pString.Substring(0, Math.Min(pLength, pString.Length)) End Function ''' ''' Replaces single quotes in text for SQL Commands. ''' ''' The string ''' The escaped string. Public Function EscapeForSQL(pString As String) As String Return Utils.NotNull(pString, String.Empty).Replace("'", "''") End Function End Module