'********************************************************************

'*

'* Function LPadString

'*

'*   Author: NetworkAdminKB.com

'*  Created: 2006-06-09

'* Modified: 2008-12-06

'*

'* Purpose: Pad the begining of a string with the specified character

'*            until it is the specified length.

'*

'* Input:   strAny = The string to pad

'*          intLen = The total string length after padding

'*          strPad = The character string to prefix strAny with.

'*

'* Output:  Returns the string prefixed with the specified character

'*           to the specified length.

'*          Returns the existing string if Length(strAny) >= intLen

'*          Returns Empty if an error occured.

'*

'********************************************************************

Function LPadString(ByVal strAny, ByVal intLen, ByVal strPad)

  'Version 1.1 2008-12-06

  Dim strTemp, x

 

  If Len(strPad) <> 1 Then

    Wscript.Echo "LPadString: strPad must be one character in length."

    LPadString = Empty

    Exit Function

  End If 'Len(strPad) <> 1

 

  If Len(strAny) < intLen Then

    For x = 1 to (intLen - Len(strAny))

      strTemp = strTemp & strPad

    Next 'x

    LPadString = strTemp & strAny

  Else

    LPadString = strAny

  End If 'Len(strAny) < intLen

 

End Function 'LPadString

Article ID: 405, Created On: 9/25/2011, Modified: 9/25/2011