Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PADR()
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: PADR()
Miscellaneous
Thread ID:
00348534
Message ID:
00348702
Views:
16
>Is there an equivilant VBA function to the PADR() function in fox?
John's code works if you want to pad spaces. If you want to pad another character try:
Function PadR(lStr As String, lLength As Long, lPadChar As String) As String
    Dim lsPad As String, lsTmp As String
    Dim llen As Long
    
    If lLength < 0 Then
        PadR = ""
        Exit Function
    End If
    ' must pass a character value; if empty string use default " "
    ' you could make the lPadChar Optional but then you have to check
    ' datatype as well
    If lPadChar = "" Then
        lsPad = " "
    Else
        lsPad = lPadChar
    End If
    
    If Len(Trim(lStr)) >= lLength Then
        PadR = Left(lStr, lLength)
        Exit Function
    End If
    
    lsTmp = Trim(lStr)
    llen = Len(lsTmp)
    PadR = lsTmp & String(lLength - llen, lsPad)
End Function
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform