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 getDay: string; private {private declarations}
Var Form1: TFORM1;
IMPLEMENTATION
/ function TFORM1.GETDAY: STRING; // Give Japan; Var Day: String; Begin Day: = COPY (Lablededit1.Text, 13, 2); if (StrtOINT (DAY)> 0) And (STRTOINT (DAY) <32 ) The begin getday: = day 'day; ELSE BEGIN SHOWMESAGE ('); "); exit; self.labelededit1.setfocus; end; end; // // function tform1.getmonth: string; / / Give the month; var month: string; begin month: = copy (labeledededit1.text, 11, 2); if (STRTOINT (MONTH) <1) OR (STRTOINT (MONTH)> 12) THEN BEGIN SHOWMESSAGE ('Enter the month) Wrong! '); Exit; self.labeledededit1.setfocus; end else begin getmonth: = month ' month '; end; end; // // function tform1.getyear: string; // var year: string; begin // Get the year; Year: = Copy (labelededitedit1.text, 7, 4); if (StrtOINT (YEAR) <1900) OR (StrtOINT (YEAR)> 2000) THEN BEGIN SHOWMESSAGE ('Enter a mistake! ! ! '); Exit; self.labeledededit1.setfocus; end; = year ' year; end; end; /// {$ r * .dfm} procedure tform1.bitbtn2click (sender: TOBJECT); begin close; ;
Procedure TForm1.bitbtn1click (Sender: TOBJECT); VAR WI, I: Integer; Sum: Integer; AI: Integer; STR1, STR2, STR3, STR4, STR5, STR6: String; Begin
IF (self.labeledededit1.text) = 15) or (length (self.labeleditedit1.text) = 18) Then Begin if length (self.labelededitedit1.text) = 15 THEN Begin
Str5: = copy (labeledededit1.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 shli 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.Labledededit1.text: = str2; end; if strand (copy (labeledit1.text, 15, 3)) MOD 2 = 0 THEN BEGIN STR3: = 'is MM! ! '; ShowMessage (Str3 ' ' ' Her birthday is ' getyear getmonth getday; ELSE BEGIN STR3: =' is a handsome guy! ! '; ShowMessage (Str3 ' ' ' His birthday is ' getYear getMonth getDay); End; Else Begin ShowMessage (the number of ID card is 15 or 18, please enter correctly !!'); Self. LablededIt1.Setfocus; end;
Procedure TFORM1.LABELEDIT1KEYPRESS (Sender: Tobject; Var Key: Char); Begin if Not (Key In ['0' .. '9', # 13, # 8]) THEN Key: = # 0; if key = char ( # 13). Self.bitbtn1.setfocus; end;
December 17, 2004