Function CheckID(InputID)
CheckID = "False"
InputID = UCase(InputID)
1.必需10個字元.
IF InputID <> "" AND Len(InputID) = 10 THEN
IF ASC(Left(InputID,1)) < 64 OR ASC(Left(InputID,1)) > 91 THEN
CheckID = "ERR-2"
身份證字號的第一碼必需是合法的英文字母
ELSEIF MID(InputID,2,1) <> "1" AND MID(InputID,2,1) <> "2" THEN
CheckID = "ERR-3"
身份證字號的第二碼必需是數字 1 或 2
ELSE
FOR i = 2 to Len(InputID)
IF ASC(Mid(InputID,i,1)) < 47 OR ASC(Mid(InputID,i,1)) > 58 THEN CheckID = "ERR-4"
身份證字號的後九碼必需是數字
NEXT
END IF
IF Mid(CheckID,1,3) <> "ERR" THEN
ID_ABC_Data = "A10B11C12D13E14F15G16H17I34J18K19L20M21N22O35P23Q24R25S26T27U28V29W30X31Y32Z33"
InputID = Mid(ID_ABC_Data,InStr(ID_ABC_Data,Left(InputID,1)) + 1,2) & Mid(InputID,2)
GetNo = 2
SUM = Left(InputID,1)
FOR i = 9 TO 1 STEP -1
SUM = SUM + Mid(InputID,GetNo,1) * i
GetNo = GetNo + 1
NEXT
IF ASC(Right(InputID,1)) = ASC(Right(10 - Right(SUM,1),1)) THEN CheckID = "True"