unit Pruefziffer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Math;
type
TForm1 =
class(TForm)
Schliessen: TButton;
Berrechnung: TButton;
edit1: TEdit;
Label1: TLabel;
procedure ButtonSchliessenClick(Sender:Tobject);
procedure ButtonBerrechnungClick(Sender:TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonSchliessenClick(Sender: TObject);
begin
close;
end;
procedure TForm1.ButtonBerrechnungClick(Sender:TObject);
var
PNR:
String;
NR1,NR2,NR3,NR4,NR5,NR6,NR7,NR8:
String;
NR1INT,NR2INT,NR3INT,NR4INT,NR5INT,NR6INT,NR7INT,NR8INT: Integer;
NR2STR, NR4STR, NR6STR, NR8STR:
String;
NR2TEST1, NR2TEST2, NR4TEST1, NR4TEST2, NR6TEST1, NR6TEST2, NR8TEST1, NR8TEST2: Integer;
NR1B,NR2B,NR3B,NR4B,NR5B,NR6B,NR7B,NR8B: Integer;
Pruefziffer: Integer;
Pruefziffershow:
String;
begin
PNR:= edit1.text;
if length(PNR) <>8
then
ShowMessage ('
Nummer muss 8. Stellig sein')
else
NR1 := Copy (PNR, 1, 1);
NR2 := Copy (PNR, 2, 1);
NR3 := Copy (PNR, 3, 1);
NR4 := Copy (PNR, 4, 1);
NR5 := Copy (PNR, 5, 1);
NR6 := Copy (PNR, 6, 1);
NR7 := Copy (PNR, 7, 1);
NR8 := Copy (PNR, 8, 1);
NR1INT:= StrToInt(NR1);
NR2INT:= StrToInt(NR2);
NR3INT:= StrToInt(NR3);
NR4INT:= StrToInt(NR4);
NR5INT:= StrToInt(NR5);
NR6INT:= StrToInt(NR6);
NR7INT:= StrToInt(NR7);
NR8INT:= StrToInt(NR8);
NR1B:= NR1INT*1;
if NR2INT*2<10
then
begin NR2B:=NR2INT*2
end
else
begin
NR2STR:= INTtoStr(NR2INT*2);
NR2TEST1 := StrToInt (Copy (NR2STR,1,1));
NR2TEST2 := StrToInt (Copy (NR2STR,2,1));
NR2B:= NR2TEST1+NR2TEST2
end;
NR3B:= NR3INT*1;
if NR4INT*2<10
then
begin NR4B:=NR4INT*2
end
else
begin
NR4STR:= INTtoStr(NR4INT*2);
NR4TEST1 := StrToInt (Copy (NR4STR,1,1));
NR4TEST2 := StrToInt (Copy (NR4STR,2,1));
NR4B:= NR4TEST1+NR4TEST2
end;
NR5B:= NR5INT*1;
if NR6INT*2<10
then
begin NR6B:=NR6INT*2
end
else
begin
NR6STR:= INTtoStr(NR6INT*2);
NR6TEST1 := StrToInt (Copy (NR6STR,1,1));
NR6TEST2 := StrToInt (Copy (NR6STR,2,1));
NR6B:= NR6TEST1+NR6TEST2
end;
NR7B:= NR7INT*1;
if NR8INT*2<10
then
begin NR8B:=NR8INT*2
end
else
begin
NR8STR:= INTtoStr(NR8INT*2);
NR8TEST1 := StrToInt (Copy (NR8STR,1,1));
NR8TEST2 := StrToInt (Copy (NR8STR,2,1));
NR8B:= NR8TEST1+NR8TEST2
end;
Pruefziffer:= NR1B+NR2B+NR3B+NR4B+NR5B+NR6B+NR7B+NR8B;
Pruefziffershow:= IntToStr (ceil(Pruefziffer/10)*10-Pruefziffer);
Label1.Caption := PNR+Pruefziffershow;
end;
end.