첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ 법인등록번호 검증하기 예제

Private Sub CommandButton1_Click()

    MsgBox CheckCorporationRegistrationNumber("1801110330380")

End Sub

 

▶ 법인등록번호 검증하기

Public Function CheckCorporationRegistrationNumber(ByVal strSource As String) As Boolean

    Dim nCheck  As Integer

    strSource = Trim(strSource)

    strSource = Replace(strSource, " ", "")

    strSource = Replace(strSource, "-", "")

    strSource = Replace(strSource, "/", "")

    If Len(strSource) <> 13 Then

        CheckCorporationRegistrationNumber = False

        Exit Function

    End If

    nCheck = nCheck + Mid(strSource, 1, 1) * 1
    nCheck = nCheck + Mid(strSource, 2, 1) * 2
    nCheck = nCheck + Mid(strSource, 3, 1) * 1
    nCheck = nCheck + Mid(strSource, 4, 1) * 2
    nCheck = nCheck + Mid(strSource, 5, 1) * 1
    nCheck = nCheck + Mid(strSource, 6, 1) * 2
    nCheck = nCheck + Mid(strSource, 7, 1) * 1
    nCheck = nCheck + Mid(strSource, 8, 1) * 2
    nCheck = nCheck + Mid(strSource, 9, 1) * 1
    nCheck = nCheck + Mid(strSource, 10, 1) * 2
    nCheck = nCheck + Mid(strSource, 11, 1) * 1
    nCheck = nCheck + Mid(strSource, 12, 1) * 2

    nCheck = nCheck Mod 10

    nCheck = 10 - nCheck

    If nCheck > 9 Then

        nCheck = 0

    End If

    If nCheck = Mid(strSource, 13, 1) Then

        CheckCorporationRegistrationNumber = True

    Else

        CheckCorporationRegistrationNumber = False

    End If

End Function
                    
        
728x90
반응형
그리드형(광고전용)
Posted by icodebroker
TAG ,

댓글을 달아 주세요