Bonjour,
J'ai besoin d'un algorihme pour controler et générer une clé rib à partir des 3 paramètres suivants:
- code banque
- code guichet
- numéro de compte
Merci et bonne jounrée
Bonjour,
J'ai besoin d'un algorihme pour controler et générer une clé rib à partir des 3 paramètres suivants:
- code banque
- code guichet
- numéro de compte
Merci et bonne jounrée
Voici 1 appli qui le fait :
Le DFM:
le PAS:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145 object Form1: TForm1 Left = 388 Top = 178 ActiveControl = Edit1 BorderStyle = bsDialog Caption = 'Calcul et contrôle de clé RIB' ClientHeight = 223 ClientWidth = 278 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -13 Font.Name = 'System' Font.Style = [] OldCreateOrder = True PixelsPerInch = 96 TextHeight = 16 object Label1: TLabel Left = 26 Top = 24 Width = 85 Height = 16 Caption = 'Code banque' end object Label2: TLabel Left = 26 Top = 53 Width = 84 Height = 16 Caption = 'Code guichet' end object Label3: TLabel Left = 26 Top = 81 Width = 86 Height = 16 Caption = 'N° de compte' end object Label4: TLabel Left = 26 Top = 110 Width = 49 Height = 16 Caption = 'Clé RIB' end object Label5: TLabel Left = 181 Top = 110 Width = 75 Height = 16 AutoSize = False Font.Charset = DEFAULT_CHARSET Font.Color = clRed Font.Height = -13 Font.Name = 'System' Font.Style = [fsBold] ParentFont = False end object BitBtn1: TBitBtn Left = 4 Top = 195 Width = 30 Height = 26 Hint = 'Quitter' ParentShowHint = False ShowHint = True TabOrder = 5 TabStop = False OnClick = BitBtn1Click Glyph.Data = { 76010000424D7601000000000000760000002800000020000000100000000100 04000000000000010000120B0000120B00001000000000000000000000000000 800000800000008080008000000080008000808000007F7F7F00BFBFBF000000 FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00330000000000 03333377777777777F333301BBBBBBBB033333773F3333337F3333011BBBBBBB 0333337F73F333337F33330111BBBBBB0333337F373F33337F333301110BBBBB 0333337F337F33337F333301110BBBBB0333337F337F33337F333301110BBBBB 0333337F337F33337F333301110BBBBB0333337F337F33337F333301110BBBBB 0333337F337F33337F333301110BBBBB0333337F337FF3337F33330111B0BBBB 0333337F337733337F333301110BBBBB0333337F337F33337F333301110BBBBB 0333337F3F7F33337F333301E10BBBBB0333337F7F7F33337F333301EE0BBBBB 0333337F777FFFFF7F3333000000000003333377777777777333} NumGlyphs = 2 end object Edit1: TEdit Left = 144 Top = 20 Width = 48 Height = 24 MaxLength = 5 TabOrder = 0 end object Edit2: TEdit Left = 144 Top = 49 Width = 48 Height = 24 MaxLength = 5 TabOrder = 1 end object Edit3: TEdit Left = 144 Top = 77 Width = 95 Height = 24 MaxLength = 11 TabOrder = 2 end object Edit4: TEdit Left = 144 Top = 106 Width = 24 Height = 24 MaxLength = 2 TabOrder = 3 end object BitBtn2: TBitBtn Left = 94 Top = 144 Width = 89 Height = 33 Font.Charset = DEFAULT_CHARSET Font.Color = clRed Font.Height = -13 Font.Name = 'System' Font.Style = [fsBold] ParentFont = False TabOrder = 4 OnClick = BitBtn2Click Glyph.Data = { 76010000424D7601000000000000760000002800000020000000100000000100 04000000000000010000120B0000120B00001000000000000000000000000000 800000800000008080008000000080008000808000007F7F7F00BFBFBF000000 FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00337000000000 73333337777777773F333308888888880333337F3F3F3FFF7F33330808089998 0333337F737377737F333308888888880333337F3F3F3F3F7F33330808080808 0333337F737373737F333308888888880333337F3F3F3F3F7F33330808080808 0333337F737373737F333308888888880333337F3F3F3F3F7F33330808080808 0333337F737373737F333308888888880333337F3FFFFFFF7F33330800000008 0333337F7777777F7F333308000E0E080333337F7FFFFF7F7F33330800000008 0333337F777777737F333308888888880333337F333333337F33330888888888 03333373FFFFFFFF733333700000000073333337777777773333} NumGlyphs = 2 end end
Ca été créé sous Delphi1, mais je viens de le compiler en D6P et c'est Ok.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118 unit Clerib0; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons,chaine; type TForm1 = class(TForm) BitBtn1: TBitBtn; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; BitBtn2: TBitBtn; Label5: TLabel; procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); private { Private-déclarations } public { Public-déclarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.BitBtn1Click(Sender: TObject); begin Form1.Close; end; procedure TForm1.BitBtn2Click(Sender: TObject); var cpte,tout:string; i,j,k,valcle,clecal:longint; begin BitBtn2.Caption:=''; Label5.caption:=''; if Edit1.Text='' then begin MessageDlg('Le code banque est obligatoire.',mtError,[ mbOK],0); Edit1.SetFocus; exit; end; if Length(Edit1.Text)<>5 then begin MessageDlg('Code banque invalide.',mtError,[ mbOK],0); Edit1.SetFocus; exit; end; if not Numeric(Edit1.Text) then begin MessageDlg('Le code banque doit être numérique.',mtError,[ mbOK],0); Edit1.SetFocus; exit; end; if Edit2.Text='' then begin MessageDlg('Le code guichet est obligatoire.',mtError,[ mbOK],0); Edit2.SetFocus; exit; end; if Length(Edit2.Text)<>5 then begin MessageDlg('Code guichet invalide.',mtError,[ mbOK],0); Edit2.SetFocus; exit; end; if not Numeric(Edit2.Text) then begin MessageDlg('Le code guichet doit être numérique.',mtError,[ mbOK],0); Edit2.SetFocus; exit; end; if Edit3.Text='' then begin MessageDlg('Le n° de compte est obligatoire.',mtError,[ mbOK],0); Edit3.SetFocus; exit; end; cpte:=Majuscules(Edit3.Text); valcle:=0; if Edit4.Text<>'' then begin if not Numeric(Edit4.Text) then begin MessageDlg('La clé RIB doit être numérique.',mtError,[ mbOK],0); Edit4.SetFocus; exit; end; if length(Edit4.Text)<>2 then begin MessageDlg('Clé RIB invalide.',mtError,[ mbOK],0); Edit4.SetFocus; exit; end; valcle:=StrToInt(Edit4.Text); if (valcle<1) or (valcle>97) then begin MessageDlg('Clé RIB hors limites (01-97).',mtError,[ mbOK],0); Edit4.SetFocus; exit; end; end; cpte:=Translate(cpte,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','12345678912345678923456789'); while Length(cpte)<>11 do cpte:='0'+cpte; { Edit3.Text:=cpte; } tout:=Edit1.Text+Edit2.Text+cpte; i:=StrToInt(_Left(tout,7)); j:=StrToInt(Copy(tout,8,7)); k:=StrToInt(_Right(tout,7)); clecal:=97-(((62*i)+(34*j)+(3*k)) mod 97); BitBtn2.Caption:=_Right('0'+IntToStr(clecal),2); if valcle<>0 then if valcle<>clecal then Label5.caption:='erronée !'; end; end.
"Il n'y a pas de bonnes réponses à une mauvaise question." (M. Godet)
-----------------------
Pensez à cloturer votre sujet- Aucune réponse aux sollicitations techniques par MP
Usus magister est optimus
En plus:
le DPR:
et la fonction principale appelée: les autres sont "self-explanatory" (Numeric, _left, Majuscules, etc...) et sont à remplacer par leur équivalent "constructeur"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 program Clerib; uses Forms, Clerib0 in 'CLERIB0.PAS' {Form1}; {$R *.RES} begin Application.CreateForm(TForm1, Form1); Application.Run; end.![]()
afin de se passer de l'unité chaine
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 Function Translate(ch_entree,cherche,remplace:string):string; var i,j:integer; Begin for i:=1 to length(ch_entree) do for j:=1 to length(cherche) do if ch_entree[i]=cherche[j] then ch_entree[i]:=remplace[j]; Translate:=ch_entree; End;
"Il n'y a pas de bonnes réponses à une mauvaise question." (M. Godet)
-----------------------
Pensez à cloturer votre sujet- Aucune réponse aux sollicitations techniques par MP
Usus magister est optimus
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager