Public Sub ValidateID(ByVal IDno As String)

Dim a As Integer = 0
For i As Integer = 0 To 5
a += CInt(ID.Substring(i * 2, 1))
Next

Dim b As Integer = 0
For i As Integer = 0 To 5
b = b * 10 + CInt(ID.Substring(2 * i + 1, 1))
Next
b *= 2
Dim c As Integer = 0
Do
c += b Mod 10
b = CInt(Int(b / 10))
Loop Until b <= 0
c += a
Dim d As Integer = 0
d = 10 - (c Mod 10)
If (d = 10) Then d = 0
If (d = CInt(mID.Substring(12, 1))) And (IsDate("19" & mID.Substring(0, 2) & "/" & mID.Substring(2, 2) & "/" & mID.Substring(4, 2)) Or IsDate("20" & mID.Substring(0, 2) & "/" & mID.Substring(2, 2) & "/" & mID.Substring(4, 2))) Then

MessageBox.Show("Invalid ID number")

Else
ID = InputBox("Enter the Identity Number of the parrot")

End If

End Sub 'Validate

Public Sub ValidateID(ByVal IDno As String)

        Dim a As Integer = 0
        For i As Integer = 0 To 5
            a += CInt(ID.Substring(i * 2, 1))
        Next

        Dim b As Integer = 0
        For i As Integer = 0 To 5
            b = b * 10 + CInt(ID.Substring(2 * i + 1, 1))
        Next
        b *= 2
        Dim c As Integer = 0
        Do
            c += b Mod 10
            b = CInt(Int(b / 10))
        Loop Until b <= 0
        c += a
        Dim d As Integer = 0
        d = 10 - (c Mod 10)
        If (d = 10) Then d = 0
        If (d = CInt(mID.Substring(12, 1))) And (IsDate("19" & mID.Substring(0, 2) & "/" & mID.Substring(2, 2) & "/" & mID.Substring(4, 2)) Or IsDate("20" & mID.Substring(0, 2) & "/" & mID.Substring(2, 2) & "/" & mID.Substring(4, 2))) Then

            MessageBox.Show("Invalid ID number")

        Else
            ID = InputBox("Enter the Identity Number of the parrot")

        End If

    End Sub 'Validate

I'm not sure what exactly your question is here? Also can you give more details about the id number itself and what your trying to accomplish? Is this a barcode?

One suggestion right off the top is to change this into a Function to return true if valid and false if not.

I am trying to validate A property method, of the 13 digits bar code!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.