Salut tout le monde
Je suis entrain d'apprendre le langage, alors peut être que je n'utilise pas la bonne chose mais j'aimerais savoir pourquoi ce que je tente de faire ne fonctionne pas.
Je sais pas pourquoi, je ne suis pas capable d'ajouter un autre IF dans le second code.
Ce code fonctionne bien:
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 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) editdoggy: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; doggycheck: TButton; test: TEdit; procedure doggycheckClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; gy: string; robert: string; good: string; bissonnette: string; Bissonnette2: string; number: integer; implementation {$R *.dfm} procedure TForm1.doggycheckClick(Sender: TObject); begin gy := editdoggy.Text; test.text := gy; robert := 'robert'; bissonnette := 'bissonnette'; bissonnette2 := 'Bissonnettte'; good := 'good'; If gy = robert then begin messagedlg('Ton nom pas ton prenom', mtinformation, [mbok], 0); end else begin end; If gy = bissonnette then messagedlg('Un nom prend une majuscule au debut!', mtinformation, [mbok], 0); end;
Le code que je veux avoir: (noter que je rajoute seulement un if de plus au premier code afficher en haut):
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 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) editdoggy: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; doggycheck: TButton; test: TEdit; procedure doggycheckClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; gy: string; robert: string; good: string; bissonnette: string; Bissonnette2: string; number: integer; implementation {$R *.dfm} procedure TForm1.doggycheckClick(Sender: TObject); begin gy := editdoggy.Text; test.text := gy; robert := 'robert'; bissonnette := 'bissonnette'; bissonnette2 := 'Bissonnettte'; good := 'good'; If gy = robert then begin messagedlg('Ton nom pas ton prenom', mtinformation, [mbok], 0); end else begin end; If gy = bissonnette then messagedlg('Un nom prend une majuscule au debut!', mtinformation, [mbok], 0); end; If gy = bissonnette2 then messagedlg('bravo!', mtinformation, [mbok], 0); end;
Ce code ne fonctionne pas, voici l'erreur donné par turbodelphi:
[Pascal Error] Unit1.pas(60): E2029 Declaration expected but 'IF' found
[Pascal Error] Unit1.pas(62): E2029 '.' expected but ';' found
[Pascal Fatal Error] Project1.dpr(5): F2063 Could not compile used unit 'Unit1.pas'
J'arrive pas à comprendre quel est le problème. Merci de m'aider.
Partager