Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Sub CheckPartitaIva(Numero As String) As Boolean
- Dim i As Integer
- Dim A As Integer
- Dim B As Integer
- Dim C As Integer
- Dim tmp As Integer
- Numero = Trim(Numero)
- If Len(Numero) <> 11 Then Return False
- For i = 1 To Len(numero)
- If Mid(numero, i, 1) Not Like "[0123456789]" Then
- Return False
- Endif
- Next
- For i = 2 To Len(numero) Step 2
- tmp = CInt(Mid(numero, i, 1)) * 2
- If tmp > 9 Then tmp -= 9
- A += tmp
- Next
- For i = 1 To Len(numero) Step 2
- tmp = CInt(Mid(numero, i, 1))
- B += tmp
- Next
- C = A + B
- Return C Mod 10 = 0
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement