Just paste this code into a new module and change the name of the module to basStrings.
'----------------------------------------------------------------------
'
' Module Name: basStrings
' Written By: C&D Programming Corp.
' Create Date: 4/98
' Copyright: Copyright 1998 by C&D Programming Corp. Source
' code may not be reproduced except for use in a
' compiled executable. All rights reserved. If
' you would like to reprint any or all of this
' code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------
Option Explicit
Function COTWPad(sData as Variant, iLen as Integer, optional sChar as variant) as String
If IsMissing(sChar) then
sChar = Chr$(32) ' The space character.
End if
If IsNull(sData) Then
COTWPad = String$(iLen, sChar)
Exit Function
End If
If Len(sData) >= iLen then
COTWPad = Left(sData, iLen)
Else
COTWPad = sData & String$(iLen - Len(sData), sChar)
End If
Exit Function