Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I love string manipulation :)
Message
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00673152
Message ID:
00674478
Vues:
20
Fantastic. It also save in my VB folder.
Thank you!

>What do you think of this?
>
>
Option Explicit
>
>Private Sub Command1_Click()
>    MsgBox PadL("John", "X", 10)
>    MsgBox PadR("John", "X", 10)
>    MsgBox PadC("John", "X", 10)
>    MsgBox PadC("John", "X", 11)
>End Sub
>
>Private Function PadC(ByVal pstrString As String, _
>                      ByVal pstrPadChar As String, _
>                      ByVal pintLen As Integer) As String
>Dim intPad As Integer
>
>    pstrString = Trim$(pstrString)
>    intPad = CInt((pintLen - Len(pstrString)) / 2)
>    PadC = Left$(String$(intPad, pstrPadChar) & pstrString & String$(intPad + 1, pstrPadChar), pintLen)
>End Function
>
>Private Function PadL(ByVal pstrString As String, _
>                      ByVal pstrPadChar As String, _
>                      ByVal pintLen As Integer) As String
>    pstrString = Trim$(pstrString)
>    PadL = String$(pintLen - Len(pstrString), pstrPadChar) & pstrString
>End Function
>
>Private Function PadR(ByVal pstrString As String, _
>                      ByVal pstrPadChar As String, _
>                      ByVal pintLen As Integer) As String
>    pstrString = Trim$(pstrString)
>    PadR = pstrString & String$(pintLen - Len(pstrString), pstrPadChar)
>End Function
>
>
>>This is Cool Eric! I am saving this in my VB folder.
>>Have you, also ddone the PadR() and PadC()?
>>If so can I also have it? :)
>>
>>>As you discovered, there is no PadL in VB. I have created my own PadL for you (and all other listeners ... like Jean-René ;) )
>>>
>>>
Private Sub Command1_Click()
>>>    MsgBox PadL("John", "X", 6)
>>>End Sub
>>>
>>>Private Function PadL(ByVal pstrString As String, _
>>>                      ByVal pstrPadChar As String, _
>>>                      ByVal pintLen As Integer) As String
>>>    PadL = String$(pintLen - Len(pstrString), pstrPadChar) & pstrString
>>>End Function
>>>
>>>
>>>>a function on visual foxpro PADL does this:
>>>>strName = "John"
>>>>PADL(strName,6,"XX") -- returns "XXJohn"
>>>>-----------------------------------------
>>>>how do i accomplish this with visual basic?
>>>>-tia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform