[ gogi100 @ 25.04.2007. 11:38 ] @
Pokusavam da napravim jedan program gde mi je potrebno proveriti PIB (poreski identifikacioni broj).Na forumu sam nasao funkciju koja vrsi proveru. Medjutim ovaj kod mi nije bas jasan.Moze li mi ko dati blize objasnjenje ovog koda i po kojoj formuli se proveravaju brojevi PIB-a. Nije mi bas jasno kako uklopiti ovu funkciju kod mene. Procedura bi kod mene bila ovakva korisnik unese PIB u TextBox - txtPIB i kad pritisne dugme na primer cmdProvera izbaci: ako PIB nije ispravan poruku Vas PIB nje dobar.Ukoliko je PIB ok program nastavlja sa radom Code: Public Function ProveriPIB(PIB As String) Dim c0 As Integer Dim c1 As Integer Dim c2 As Integer Dim c3 As Integer Dim c4 As Integer Dim c5 As Integer Dim c6 As Integer Dim c7 As Integer Dim c8 As Integer Dim zadnji As String zadnji = Right(PIB, 1) PIB = Left(PIB, 8) If Len(PIB) <> 8 Then ProveriPIB = 1 Else c8 = (CInt(Mid(PIB, 1, 1)) + 10) Mod 10 If c8 = 0 Then c8 = 10 End If c8 = (c8 * 2) Mod 11 c7 = (CInt(Mid(PIB, 2, 1)) + c8) Mod 10 If c7 = 0 Then c7 = 10 End If c7 = (c7 * 2) Mod 11 c6 = (CInt(Mid(PIB, 3, 1)) + c7) Mod 10 If c6 = 0 Then c6 = 10 End If c6 = (c6 * 2) Mod 11 c5 = (CInt(Mid(PIB, 4, 1)) + c6) Mod 10 If c5 = 0 Then c5 = 10 End If c5 = (c5 * 2) Mod 11 c4 = (CInt(Mid(PIB, 5, 1)) + c5) Mod 10 If c4 = 0 Then c4 = 10 End If c4 = (c4 * 2) Mod 11 c3 = (CInt(Mid(PIB, 6, 1)) + c4) Mod 10 If c3 = 0 Then c3 = 10 End If c3 = (c3 * 2) Mod 11 c2 = (CInt(Mid(PIB, 7, 1)) + c3) Mod 10 If c2 = 0 Then c2 = 10 End If c2 = (c2 * 2) Mod 11 c1 = (CInt(Mid(PIB, 8, 1)) + c2) Mod 10 If c1 = 0 Then c1 = 10 End If c1 = (c1 * 2) Mod 11 c0 = (11 - c1) Mod 10 If c0 <> zadnji Then ProveriPIB = 1 Else ProveriPIB = 0 End If 'return(pib || to_char(c0)); End If End Function Hvala |