Advertisement
bousaid

VBA CLE & RIP CCP

Apr 2nd, 2024
1,044
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.34 KB | Source Code | 0 0
  1. ' =================================================================================================
  2. '  Cle CCP  | By BOUSSAID
  3. ' =================================================================================================
  4. Private Function CCP(x As String)
  5.  
  6. Dim TCCP1(1 To 15) As Integer
  7. Dim IND As Integer
  8. J = 0
  9. For IND = 1 To Len(x)
  10.     TCCP1(IND) = Mid(x, IND, 1)
  11.     Next
  12.     For IND = 4 To 4 + Len(x) - 1
  13.         ac = ac + (TCCP1(Len(x) - J) * IND)
  14.         J = J + 1
  15.         Next
  16.         ac = Right(ac, 2)
  17.         'tcptxt = ac & " Clé " & tcptxt
  18.         CCP = ac
  19. End Function
  20. ' =================================================================================================
  21. '  CLE & RIP CCP  | Usage: =Cle_CCP_RIP(1;A1) & =Cle_CCP_RIP(2;A1)
  22. ' =================================================================================================
  23. Public Function Paie_Cle_CCP_RIP(Type_Cle As Integer, Compte_CCP As String) As String
  24.  
  25. Dim nResulta As Integer
  26.  
  27. Select Case Type_Cle
  28.     '1 = Cle CCP
  29.     Case 1
  30.        nResulta = CLng(CCP(Compte_CCP))
  31.        
  32.     '2 = Cle Rip
  33.     Case 2
  34.         nResulta = (97 - ((((CLng(Compte_CCP) Mod 97) * (3 Mod 97)) + 85) Mod 97))
  35.     Case Else
  36.         nResulta = 0
  37. End Select
  38.  
  39. 'ADD "0" Like 01, 02, 03 ... etc
  40. Paie_Cle_CCP_RIP = CStr(Format(nResulta, "00")) 'CStr(nResulta)
  41.  
  42. End Function
Tags: vba dz ccp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement