CalcoloCAP




Function CAP(Localita, Pr As String) As String
Dim Lo1, Lo2, p As String, D, M, E As Integer

'Nota: Per funzionare bisogna linkare tutta

'la procedura per il calcolo completo del

'codice fiscale


Localita = StrConv(Localita, vbUpperCase)
D = Len(Localita)
If D > 18 Then D = 18
p = StrConv(Pr, vbUpperCase)
M = 2

Lo1 = ""
Lo2 = ""

For i = 1 To D
Lo1 = Mid(Localita, i, 1)
If Lo1 = " " Then Lo1 = ""
If Lo1 = "'" Then Lo1 = ""
If Lo1 = "-" Then Lo1 = ""
If Lo1 = "." Then Lo1 = ""
If Lo1 = "À" Then Lo1 = "A"
If Lo1 = "È" Then Lo1 = "E"
If Lo1 = "É" Then Lo1 = "E"
If Lo1 = "Ì" Then Lo1 = "I"
If Lo1 = "Ò" Then Lo1 = "O"
If Lo1 = "Ù" Then Lo1 = "U"
Lo2 = Lo2 + Lo1
Next i

If p = "" Then GoTo Vai
If Not p Like "[A-Z][A-Z]" Then MsgBox ("Inserire le due cifre relative alla Provincia")
Vai:
E = Len(Lo2)

If CAP = "" Then CAP = Loc1(Lo2, p, E, M)
If CAP = "" Then CAP = Loc2(Lo2, p, E, M)
If CAP = "" Then CAP = Loc3(Lo2, p, E, M)
If CAP = "" Then CAP = Loc4(Lo2, p, E, M)
If CAP = "" Then CAP = Loc5(Lo2, p, E, M)
If CAP = "" Then CAP = Loc6(Lo2, p, E, M)
If CAP = "" Then CAP = Loc7(Lo2, p, E, M)
If CAP = "" Then CAP = Loc8(Lo2, p, E, M)
If CAP = "" Then CAP = Loc9(Lo2, p, E, M)
If CAP = "" Then CAP = Loc10(Lo2, p, E, M)
If CAP = "" Then CAP = Loc11(Lo2, p, E, M)
If CAP = "" Then CAP = Loc12(Lo2, p, E, M)
If CAP = "" Then CAP = Loc13(Lo2, p, E, M)

End Function










( calcolocap.html )- by Paolo Puglisi - Modifica del 17/12/2023