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

'*

'* Function RPadString

'*

'*   Author: NetworkdAdminKB.com

'*  Created: 2007-01-07

'* Modified: 2007-01-07

'*

'* Purpose: On the right side Pad 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 suffix strAny with.

'*

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

'*            to the specified length.

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

'*          Returns Empty if an error occurs

'*

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

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

  'Version: 1.0 2007-01-07

  Dim strTemp, x

 

  If Len(strPad) <> 1 Then

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

    RPadString = 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

    RPadString = strAny & strTemp

  Else

    RPadString = strAny

  End If 'Len(strAny) < intLen

 

End Function 'RPadString

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