Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Access 97 and pad function
Message
 
 
À
18/07/2000 10:44:36
Information générale
Forum:
Visual Basic
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00393811
Message ID:
00394397
Vues:
11
>Is there a function that would do the same as lpad (for example) in Access 97 ? I need to concatenate fields from a table and base the concatenation on the lenght of the field and not on the lenght of the text in the fields, so i would be able to put blank to fill the lack between the lenght of the text and the original lenght of the fields

No there isn't. You have to create you own. Here one I implemented if it helps:
Function PadL(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
        PadL = ""
        Exit Function
    End If
    
    If lPadChar = "" Then
        lsPad = " "
    Else
        lsPad = lPadChar
    End If
    
    If Len(Trim(lStr)) >= lLength Then
        PadL = Left(lStr, lLength)
        Exit Function
    End If
    
    lsTmp = Trim(lStr)
    llen = Len(lsTmp)
    PadL = String(lLength - llen, lsPad) & lsTmp
End Function
This was mirrored after the VFP function of the same name. You can pad a string up to any size and define the character to use to pad it with. If the padded size is less than the size of the string, then it truncates it.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform