Page 1 sur 1

@repeat en LS

MessagePublié: 22 Juil 2005 à 17:58
par Michael DELIQUE
Code : Tout sélectionner
Function Repeat_LS(wChaine As String,wnbRepeat As Integer, wnbTailleMaxi As Integer) As String   
   
   'si la taille maximum est négative la chaine sera tronqué par la gauche
   
   'Déclaration Variable
   Dim I As Integer
   
   On Error Goto ErreurRepeat_LS
   
   If wChaine = "" Then
      Repeat_LS = ""
      Exit Function
   End If
   
   If Abs(wnbRepeat) = 0 Then
      Repeat_LS = wChaine
      Exit Function
   End If
   
   Repeat_LS = ""
   
   For i = 1 To Abs(wnbRepeat)
      Repeat_LS = Repeat_LS+wChaine
   Next
   
   If Len(Repeat_LS) > Abs(wnbTailleMaxi) Then
      If wnbTailleMaxi > 0 Then
         Repeat_LS = Left(Repeat_LS,wnbTailleMaxi )
      Elseif  wnbTailleMaxi < 0 Then
         Repeat_LS = Right(Repeat_LS,wnbTailleMaxi )
      End If
   End If
   
   I = 0
   
   Exit Function
ErreurRepeat_LS:
   Msgbox "(Repeat_LS) Erreur " + Str(Err) + " : " + Cstr(Error)+Chr(10)+"Ligne N° "+Cstr(Erl),16, " ERREUR !"
   I = 0   
   Repeat_LS = ""
   Exit Function
End Function