page 62 de 93
7.7.3 Code
Une fois ce formulaire établi, nous devons programmer le code nécessaire.
Voici un exemple d’implémentation.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls;
type
TfrmMatricule = class(TForm)
lblTitre: TLabel;
lblSaisie: TLabel;
lblResultat: TLabel;
edtSaisie: TEdit;
edtResultat: TEdit;
btnVerif: TButton;
lblResultat: TLabel;
btnExit: TButton;
procedure btnVerifClick(Sender: TObject);
procedure btnExitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; //Tformulaire
var
frmMatricule: TfrmMatricule;
implementation
{$R *.dfm}
procedure TfrmMatricule.btnVerifClick(Sender: TObject);
var
a1,a2,a3,a4,m1,m2,j1,j2,n1,n2,nc,c: integer;
sum : integer;
s : string;
begin
s:=edtSaisie.Text;
if length(s) <> 11 then
ShowMessage('Numéro de matricule mal saisi')
else
begin
a1:= StrToInt(copy(s,1,1));
a2:= StrToInt(copy(s,2,1));
a3:= StrToInt(copy(s,3,1));
a4:= StrToInt(copy(s,4,1));
m1:= StrToInt(copy(s,5,1));
m2:= StrToInt(copy(s,6,1));
j1:= StrToInt(copy(s,7,1));
Comentarios a estos manuales