SHARE
TWEET

CheckPartitaIva

metallaro1980 Mar 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub CheckPartitaIva(Numero As String) As Boolean
  2.   Dim i As Integer
  3.   Dim A As Integer
  4.   Dim B As Integer
  5.   Dim C As Integer
  6.   Dim tmp As Integer
  7.   Numero = Trim(Numero)
  8.   If Len(Numero) <> 11 Then Return False  
  9.   For i = 1 To Len(numero)
  10.     If Mid(numero, i, 1) Not Like "[0123456789]" Then
  11.       Return False
  12.     Endif
  13.   Next
  14.  
  15.   For i = 2 To Len(numero) Step 2
  16.     tmp = CInt(Mid(numero, i, 1)) * 2
  17.     If tmp > 9 Then tmp -= 9
  18.     A += tmp    
  19.   Next
  20.  
  21.   For i = 1 To Len(numero) Step 2
  22.     tmp = CInt(Mid(numero, i, 1))
  23.     B += tmp    
  24.   Next
  25.  
  26.   C = A + B
  27.   Return C Mod 10 = 0
  28.  
  29.  
  30. End
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top