Skip to main content
NetworkAdminKB Logo

VBScript Library

Go Search
NetworkAdminKB.com
Knowledge Base
VBScript Library
Utilities
  
NetworkAdminKB.com > VBScript Library > Knowledge Base > Components > Strings > RPadString  

RPadString

Article Content

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

'*

'* 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

Keywords
String Concatenation 
Related Articles
 
Last modified at 11/1/2009 12:39 PM  by TEMPLATE\kbadmin 
 
 NetworkAdminKB.com
 Copyright © 2008 NetworkAdminKB.com, All rights reserved. Terms of Use | Contact US