Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code for PADL,PADC,PADR :)
Message
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Titre:
Code for PADL,PADC,PADR :)
Divers
Thread ID:
00419783
Message ID:
00419783
Vues:
53
Eric cut a little dity loose here and it got me missing the VFP PAD functions. Eric's the man. I am also uploading this to the files area for other foxheads moving into VB's string manipulation.
' *******************************************************************
' Thanks go to Éric Moreau for this one!! I renamed to PadL and made
' a small change to param order to allow optional padchar Now
' PADC,PADL,PADR works just like momma used to make  :)
Public Function PadR(ByVal pstrSource As String, _
                    ByVal pintLen As Integer, _
                    Optional ByVal pstrFiller As String = " ") As String
    PadR = Left$(Trim$(pstrSource) & String$(pintLen, pstrFiller), pintLen)
End Function

Public Function PadL(ByVal pstrSource As String, _
                    ByVal pintLen As Integer, _
                    Optional ByVal pstrFiller As String = " ") As String
    PadL = Right$(String$(pintLen, pstrFiller) & Trim$(pstrSource), pintLen)
End Function

Public Function PadC(ByVal pstrSource As String, _
                    ByVal pintLen As Integer, _
                    Optional ByVal pstrFiller As String = " ") As String
    ' Used pintLen - (pintLen - 2) and pintLen / 2 to allow non even values
    ' maintaining desired endlength as odd numbers would show up 1 character short
    PadC = Right$(String$(pintLen - (pintLen / 2), pstrFiller) & Trim$(pstrSource) _
                & String$(pintLen \ 2, pstrFiller), pintLen)
 ' Debug.Print Len(PadC) ' Testing output
End Function
' *******************************************************************
~Joe Johnston USA

"If ye love wealth better than liberty, the tranquility of servitude better than the animated contest of freedom, go home from us in peace. We ask not your counsel or arms. Crouch down and lick the hands which feed you. May your chains set lightly upon you, and may posterity forget that ye were our countrymen."
~Samuel Adams

Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform