Flickr logo
More of Luca Mauri's photos
blank

Section's icon A snippet
Calcolare il CIN di un conto corrente
Codename: CINCalc

Il CIN (Control Internal Number) è un tipo di check digit che viene usato dalle banche italiane fin dagli anni '90. E' ancora molto utile in quanto deve essere incorporato nel codice IBAN che da metà del 2008 è sostanzialmente indispensabile per le transazioni monetarie elettroniche.
Pare che su internet ci siano pochissime fonti che spieghino come calcolarlo, l'algoritmo che segue si basa su una spiegazione del modulo Contabilità delle ACG di IBM.
L'ho provato su diversi numeri di C/C e funziona regolarmente.
Separatore

Following the full code of the snippet
You can copy and paste it from here, otherwise you can download it in .snippet file format by clicking here.

                Module modCIN
    Friend Const CINLetters As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ-. "
    Friend Const CINDigits As String = "0123456789"

    Friend Const Divisor As Integer = 26

    Friend CINEvenList As Integer() = {0, 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}
    Friend CINOddList As Integer() = {1, 0, 5, 7, 9, 13, 15, 17, 19, 21, 2, 4, 18, 20, 11, 3, 6, 8, 12, 14, 16, 10, 22, 25, 24, 23, 27, 28, 26}

    Function CalcCIN(ByVal ABI As String, ByVal CAB As String, ByVal Account As String) As String
        Dim ProperString As String
        Dim GrandTotal As Integer
        Dim Position As Integer
        Dim CurrChar As Char

        If ABI.Length <> 5 Or CAB.Length <> 5 Or Account.Length > 12 Or Account.Length < 1 Then
            Return "Lenght error in input data"
        End If

        If Account.Length = 12 Then
            ProperString = ABI & CAB & Account.ToUpper
        Else
            ProperString = ABI & CAB & Account.PadRight(12, " ").ToUpper
        End If

        GrandTotal = 0

        For i = 0 To 21
            CurrChar = ProperString(i)

            Position = CINDigits.IndexOf(CurrChar)
            If Position < 0 Then
                Position = CINLetters.IndexOf(CurrChar)
                If Position < 0 Then
                    Return "Invalid character found in position " & i
                End If
            End If

            If i Mod 2 = 0 Then
                GrandTotal += CINOddList(Position)
            Else
                GrandTotal += CINEvenList(Position)
            End If
        Next
        Return CINLetters.Substring(GrandTotal Mod Divisor, 1)
    End Function
End Module                
            

Go back to snippet page.

Gear B/N Risultato del processo OK
blank

Ajax-enabled news - Beta

Ajax News temporaneamente sospese in attesa della nuova versione.

Tag Cloud - Beta

AddThis Bookmark

Il pulsante di AddThis permette di aggiungere un segnalibro per questa pagina nei più diffusi siti internet.

Licenza

Creative Commons License
Il contenuto di questo sito internet, se non diversamente specificato, è pubblicato sotto una Licenza Creative Commons.

The content of this website is published under a Creative Commons License, unless otherwise stated.

Site Meter

ClustrMaps

Locations of visitors to this page

Elenco Feed

Questo file OPML contiene l'elenco aggiornato di tutti i feed RSS disponibili sul sito.

OPML rect

amung.us

hit counter

Random Quote

«Who am I?
You sure you want to know?
The story of my life is not for the faint of heart. If somebody said it was a happy little tale... if somebody told you I was just your average ordinary guy, not a care in the world... somebody lied. »

Peter Parker
"Spider-Man"

Leggi tutte le citazioni

Random Fact

Contrariamente a quanto comunemente si pensa, un veicolo spaziale che rientra nell'atmosfera terrestre viene riscaldato dall'attrito solo per circa il 1% del totale.
La gran parte del calore viene dalla compressione adiabatica del gas che sta davanti al veicolo: si calcola che la temperatura all'interno dell'onda d'urto possa raggiungere i 10.000 K.
Secondo i calcoli degli ingegneri della NASA, lo scudo termico della futura capsula Orion, di ritorno da un viaggio nell'orbita lunare, raggiungerà una temperatura superiore ai 2.900 K.

NASA (2005)

Leggi tutte le curiosità

aNobii Books

Sorting Hat

i'm in ravenclaw!
be sorted @ nimbo.net

LM CubeCopyright © 2000 - 2010 Luca Mauri. All rights reserved
Note sui contenuti del sito.


Generated by Luca Mauri's xCMS xCMS | ASP.net 2.0 powered Powered by ASP.net 2.0

Technology Blogs - BlogCatalog Blog Directory


Standard compliant: Valid Sitemaps | W3C CSS Valid | W3C XHTML Valid | RSS 2.0 Valid | OPML checked by validator.opml.org. | AJAX Powered


This page is generated by Luca Mauri Luca Mauri's xCMS
eXperimental Content Management System version 1.5.0.11320
Current date and time on server Tue, 07 Sep 2010 15:35:04 GMT
Took 0,47959 seconds to be created