! Attention plus difficile !

Il sagit de convertir cette fonction Visual Basic en fonction Php :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Public Function Reference(Inp)
    If Len(Inp) = 5 Then
        H = 10
        For I = 1 To 5
            Z = Mid(Inp, I, 1) + H
            Z1 = Int(Z / 10)
            Z2 = Z Mod 10
 
            If Z2 = 0 Then
                Z2 = Z2 + 10
            End If
 
            Z2 = Z2 * 2
            H = Z2 Mod 11
            Z2 = Z2 / 11
        Next
        Z = 11 - H
        Z1 = Z / 10
        Reference = Inp & (Z Mod 10)
    Else
        Reference = Inp
    End If
End Function
2ieme version
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Public Function Modul(Inp)
 
   If Len(Inp) < 5 Then
       Modul = ""
   End If
 
    H = 10
 
    For I = 1 To 5
 
      Z = Mid(Inp, I, 1) + H
      Z1 = Int(Z / 10)
      Z2 = Z Mod 10
 
      If Z2 = 0 Then
         Z2 = Z2 + 10
      End If
 
      Z2 = Z2 * 2
      H = Z2 Mod 11
      Z2 = Z2 / 11
    Next
 
    Z = 11 - H
    Z1 = Z / 10
    Modul = Z Mod 10
 
End Function