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
반응형
그리드형(광고전용)
'VB' 카테고리의 다른 글
[VB] 텍스트 파일 읽기 (0) | 2015.05.16 |
---|---|
[VB] DO UNTIL ~ EXIT DO ~ LOOP문 사용하기 (0) | 2015.05.16 |
[VB] SQL Server 연결 구하기 (윈도우즈 인증) (0) | 2015.05.16 |
[VB] SQL Server 연결 구하기 (0) | 2015.05.16 |
[VB] UBOUND 함수를 사용해 배열 상한 인덱스 구하기 (0) | 2015.05.16 |
[VB] 폼 배경에 바탕 화면 이미지 보여주기 (0) | 2015.05.16 |
[VB] 단축 아이콘 만들기 (0) | 2015.05.16 |
[VB] 메시지 박스 일정 시간 경과 후 닫기 (0) | 2015.05.16 |
[VB] ComboBox 클래스 : 포커스 획득시 드롭 다운 리스트 자동으로 보여주기 (0) | 2015.05.16 |
[VB] 비프음 연주하기 (0) | 2015.05.16 |
댓글을 달아 주세요