# 请问如何将身份证号码第一个英文转为大写?(书本~彭明柳VB中文专业版 p.312

Posted by jojo on July 14, 1999 at 23:51:08:

Option Explicit
----------------------------------------------------------
Public Function CheckID(ByVal strID As String) As Boolean
Dim lngID As Long 'id2到10码的数字
Dim intVerify1 As Integer '第一个检查码,按英文特定字母顺序加9得之
Dim intVerify2 As Integer '全部检查码之总和
Dim strFirst As String 'id第一个英文字母
Dim intCounter As Integer '计数器
Dim checkSum As Integer

strFirst = UCase(Left(strID, 1))
lngID = CLng(Mid(strID, 2))
CheckID = False
' 检查身份证号码的长度是否为10个字母
If Len(strID) <> 10 Then Exit Function
' 检查第一个身份证号码是不是英文字母
If strFirst < "A" Or strFirst > "Z" Then Exit Function
' 检查其余各码是不是数字
If Not IsNumeric(lngID) Then Exit Function
' 检查编码之正确性
intVerify1 = InStr("ABCDEFGHJKLMNPQRSTUVWXYZIO", strFirst) + 9
strID = CStr(intVerify1) & CStr(lngID)
intVerify2 = Val(Mid(strID, 1, 1))
For intCounter = 2 To 10
intVerify2 = intVerify2 + Val(Mid(strID, intCounter, 1)) * (11 - intCounter)
Next
intVerify2 = intVerify2 + Val(Mid(strID, 11, 1))
CheckID = IIf(checkSum Mod 10 = 0, True, False)
End Function

Follow Ups:

- UCase() cww 08:24:04 7/15/99 (0)