블로그 이미지
자료에 문제가 있을 경우, 확인하는대로 삭제처리 하겠습니다. 즐거운 하루 되시길...
05-01 14:40
Total
Today
Yesterday

카테고리

분류 전체보기 (199)
이야기방 (20)
공부방 (173)
개발노트&관련잡다구니 (6)

주민등록번호 검사 함수 ( '-' 을 제외한 숫자만 남긴 형태로 가공하여 매개변수로 넣어야 함)

function 주민번호체크(const s: String): Boolean; 

const weight='234567892345';

var 

  Sum, i: Integer;

  last, lastRes: Integer;

begin 

  Result:=False;


  if Length(Trim(s))<>13 then Exit

  else begin

    Sum:=0;

    for i:=1 to 12 do Sum:=Sum+(StrToInt(s[i])*StrToInt(weight[i]));


    last:=Sum mod 11;

    LastRes:=11 - last;


    if LastRes=10 then LastRes:=0

    else if LastRes=11 then LastRes:=1;


    if LastRes=StrToInt(s[13]) then Result:=True;

  end;

end; 

 

 

 

 

신용카드번호 검사 함수 ( '-' 을 제외한 숫자만 남긴 형태로 가공하여 매개변수로 넣어야 함)

function 카드번호체크(const s: String): Boolean; 

var

  tmpInt: array [0..15] of Integer;

  i: Integer;

  tmpStr: String;

  ResultInt, LastInt: Integer;

begin

  Result:=False;


  if Length(Trim(s))<>16 then Exit

  else begin

    for i:=0 to 14 do begin

      if (i mod 2)=0 then begin

        tmpInt[i]:=StrToInt(s[i+1])*2;


      if tmpInt[i]>9 then begin

        tmpStr:=IntToStr(tmpInt[i]);

        tmpInt[i]:=StrToInt(tmpStr[1])+StrToInt(tmpStr[2]);

      end;

      end

      else tmpInt[i]:=StrToInt(s[i+1]);

    end;


    ResultInt:=0;

    for i:=0 to 14 do ResultInt:=ResultInt+tmpInt[i];


    tmpStr:=IntToStr(ResultInt);

    LastInt:=10 - StrToInt(tmpStr[Length(tmpStr)]);


    if s[16]=IntToStr(LastInt) then Result:=True;

  end;

end;



원본 링크 : http://bloodguy.tistory.com/entry/Delphi-%EC%A3%BC%EB%AF%BC%EB%93%B1%EB%A1%9D%EB%B2%88%ED%98%B8-%EC%8B%A0%EC%9A%A9%EC%B9%B4%EB%93%9C%EB%B2%88%ED%98%B8-%EC%9C%A0%ED%9A%A8%EC%84%B1-%EA%B2%80%EC%82%AC

Posted by 래채
, |