Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

provera PIB-a objasnjenje

[es] :: Visual Basic 6 :: provera PIB-a objasnjenje

[ Pregleda: 9470 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

gogi100
Goran Ljubic

Član broj: 40722
Poruke: 1064
87.250.46.*



+3 Profil

icon provera PIB-a objasnjenje25.04.2007. u 11:38 - pre 206 meseci
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
 
Odgovor na temu

rgdrajko
Beograd

Član broj: 117734
Poruke: 710
80.93.249.*



+3 Profil

icon Re: provera PIB-a objasnjenje25.04.2007. u 16:39 - pre 206 meseci
Resenje je ovo:

Code:
Private Sub Command1_Click()
    provera = ProveriPIB(Text1.Text)
    If provera = 0 Then
        MsgBox "Vas PIB nije dobar, upisite novi", vbCritical, "PIB"
    End If
    If provera = 1 Then
        MsgBox "Ispravan PIB", vbInformation, "PIB"
        'neki kod kada je ispravan PIB
    End If
End Sub

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

rgdrajko
 
Odgovor na temu

gogi100
Goran Ljubic

Član broj: 40722
Poruke: 1064
87.250.46.*



+3 Profil

icon Re: provera PIB-a objasnjenje25.04.2007. u 17:50 - pre 206 meseci
Ja sam u If naredbu dodao i proveru na duzinu piba

If provera = 0 And Len(Text1.Text)<>9 Then

medjutim kad kliknem na dugme ne desava se nista.
Gde je greska
A sto se tice funkcije za proveru PIB-a izgleda da ni ona nije tacna.
Kad upotrebim samo If provera = 0 Then bez And Len(Text1.Text)<>9
kad ukucam na primer PIB 111111111 ili pib od kojih 4 znaka 3667
on mi izbacuje da je PIB ispravan.
Sta menjati hvala?
 
Odgovor na temu

gogi100
Goran Ljubic

Član broj: 40722
Poruke: 1064
87.250.46.*



+3 Profil

icon Re: provera PIB-a objasnjenje25.04.2007. u 22:08 - pre 206 meseci
U pravilniku o PIB-u sam nasao da prvih osam cifara je redni broj obveznika koji moze biti od 10000001 do 999999999.Prijatelju mozes li mi napisati opstu formulu kako se izracunava 9 cifra kontrolni broj.

Ako dobijem ovu formulu nije tesko napisati ni proveru PIB-a.
Ja sam napisao proveru - uslove ukoliko je PIB kraci ili duzi od 9 cifara, zatim zatim ukoliko je prvih 8 cifara manje od 100000001. Sad mi je potrebna opsta formula kako izracunati kontrolni broj.Kad to imam onda nije tesko napisati i proveru.
Hvala
 
Odgovor na temu

rgdrajko
Beograd

Član broj: 117734
Poruke: 710
80.93.249.*



+3 Profil

icon Re: provera PIB-a objasnjenje26.04.2007. u 00:36 - pre 206 meseci
Upisi:

Code:

Private Sub Command1_Click()
    provera = ProveriPIB(Text1.Text)
    If Len(Text1.Text) < 8 Or Len(Text1.Text) > 8 Then
        provera = 0
    End If
    If provera = 0 Then
        MsgBox "Vas PIB nije dobar, upisite novi", vbCritical, "PIB"
    End If
    If provera = 1 Then
        MsgBox "Ispravan PIB", vbInformation, "PIB"
        'neki kod kada je ispravan PIB
    End If
End Sub

rgdrajko
 
Odgovor na temu

[es] :: Visual Basic 6 :: provera PIB-a objasnjenje

[ Pregleda: 9470 | Odgovora: 4 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.