Sign in to follow this  
Followers 0
Efo74

Controllo Partita IVA

1 post in this topic

autoit

ConsoleWrite(ControllaPIVA("07643520567"))

;********************************************************************************************************************************

Func ControllaPIVA($string_check)

;********************************************************************************************************************************

;Ritorna True se la Partita IVA è formalmente corretta.

Dim $i,$carattere_estratto

Dim $X=0,$Y=0,$Z=0,$T=0

if Stringlen($string_check) <> 11 Then Return False

if StringIsDigit($string_check) = 0 Then Return False

$X = 0

for $i=1 to 11 step 2

$X += StringMid($string_check,$i,1)

Next

$Y = 0

for $i=2 to 11 step 2

$carattere_estratto = StringMid($string_check,$i,1)

$Y += $carattere_estratto

if $carattere_estratto >= 5 Then $Z += 1

Next

$Y += $Y

$T = Mod($X+$Y+$Z,10)

if $T=0 Then return True

Return False

EndFunc

/autoit


:rolleyes:

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0