身份证验证程序代码
来源:互联网 发布:网络安全工程师 待遇 编辑:程序博客网 时间:2024/05/18 21:38
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls,Math;
type
TForm1 = class(TForm)
LabeledEdit1: TLabeledEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure LabeledEdit1KeyPress(Sender: TObject; var Key: Char);
function GetYear:String;
function GetMonth:String;
function GetDay:String;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
/////////////////////////////////////////////////
function TForm1.GetDay: string; // 取得日 ;
var
Day:String;
begin
Day:=Copy(LabeledEdit1.Text,13,2);
if (Strtoint(Day)>0) and (StrToInt(Day)<32) then
begin
GetDay:=Day+'日';
end
else
begin
ShowMessage('输入的日期有错!');
exit;
Self.LabeledEdit1.SetFocus;
end;
end; //
//
function TForm1.GetMonth: String; // 取得月 ;
var
Month:string;
begin
Month:= Copy(LabeledEdit1.Text,11,2);
if (StrToInt(Month)<1) or (StrToInt(Month)>12) then
begin
ShowMessage('输入的月份有错!');
exit;
Self.LabeledEdit1.SetFocus;
end
else
begin
GetMonth:=Month+'月';
end;
end; //
//
function TForm1.GetYear: String; //
var
Year:String;
begin // 取得年;
Year:=Copy(LabeledEdit1.Text,7,4);
if (StrToInt(Year)<1900) or (StrToInt(Year)>2000) then
begin
ShowMessage('输入的年份有错!!!');
exit;
Self.LabeledEdit1.SetFocus;
end
else
begin
GetYear:=Year+'年';
end;
end; //
/////////////////////////////////////////////////
{$R *.dfm}
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
wi,I:integer;
Sum:Integer;
ai:integer;
Str1,Str2,Str3,Str4,Str5,Str6:String;
begin
if (length(self.LabeledEdit1.Text)=15) or (length(self.LabeledEdit1.Text)=18) then
begin
if length(self.LabeledEdit1.Text)=15 then
begin
Str5:=copy(LabeledEdit1.Text,1,6);
Str6:=Copy(LabeledEdit1.Text,7,9);
Str1:=Str5+'19'+Str6+'2';
Sum:=0;
for i:=0 to 17 do
begin
ai:=StrtoInt(Copy(Str1,18-i,1));
wi:=(2 shl i) mod 11;
Sum:=Sum+ai*wi;
end;
Sum:=Sum mod 11;
case Sum of
0: Str4:='1';
1: Str4:='0';
2: Str4:='x';
4: Str4:='8';
5: Str4:='7';
6: Str4:='6';
7: Str4:='5';
8: Str4:='4';
9: Str4:='3';
10:Str4:='2';
end;
Str2:=copy(Str1,1,17)+Str4;
self.LabeledEdit1.Text:=Str2;
end;
if strtoint(Copy(LabeledEdit1.Text,15,3)) mod 2=0 then
begin
Str3:='是个MM哦!!';
Showmessage(Str3+' '+'她的生日是'+GetYear+GetMonth+GetDay);
end
else
begin
Str3:='是个帅哥哦!!';
ShowMessage(Str3+' '+'他的生日是'+GetYear+Getmonth+GetDay);
end;
end
else
begin
showMessage('身份证的位数为15或18,请正确输入!!');
self.LabeledEdit1.SetFocus;
end;
end;
procedure TForm1.LabeledEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in ['0'..'9',#13,#8]) then
key:=#0;
if Key = char(#13) then
self.BitBtn1.SetFocus;
end;
end.
2004年12月17日
- 身份证验证程序代码
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 验证身份证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 身份证验证
- 验证身份证
- 身份证验证
- 身份证验证
- 感谢 Graham Bradshaw 的帮助
- 游民稗史-程序员的小说(15)
- 游民稗史-程序员的小说(后记)
- ShadowStar CodeFast 0.9 跳到上/下一个方法
- 一天几句话12.17
- 身份证验证程序代码
- 致cgf
- 暗之魔法-吞噬
- Cygwin使用指南
- Cygwin视窗下的UNIX多面手
- java编程的一点心得
- 如何去检测网络的连接状态(C#)
- 对象模型(COM)
- 烦人的问题:Client does not support authentication protocol requested by server; consider upgrading MySQL client