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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
| ' Gambas class file PUBLIC contenu AS VARIANT PUBLIC memoire AS VARIANT PUBLIC nb AS STRING PUBLIC signe AS STRING PUBLIC ope AS STRING PUBLIC comment AS STRING PUBLIC ktext AS VARIANT
PUBLIC SUB _new()
END
PUBLIC SUB Form_Open()
ME.Center signe = "+" memoire = 0 END
'***************************** Fonctions ************************************ ' Fonction - chiffre() -
SUB chiffre(nb AS STRING) 'definition de la fonction avec comme paremetre nb textBox2.Text = textBox2.Text & nb 'concatenation possible car nous saisissons des caracteres contenu = Val(textBox2.Text) ' transformation en valeur de la chaine de caractere contenu dans textBox2 CATCH ' recuperation si erreur Message.Info("nombre invalide. Saisis un nombre valide") textBox2.Clear ' remise à zero pour ressaisie si erreur
END ' ------------------------------------------------------------------ ' fonction - operation() - SUB operation(ope AS STRING) comment = Transfert.comment
IF signe = "+" THEN memoire = memoire + contenu ListBox1.Add("+" & contenu & " " & comment) textBox2.Clear ENDIF
IF signe = "-" THEN memoire = memoire - contenu ListBox1.Add("-" & contenu & " " & comment) textBox2.Clear ENDIF
IF signe = "x" THEN memoire = memoire * contenu ListBox1.Add("x" & contenu & " " & comment) textBox2.Clear ENDIF
IF signe = "/" THEN memoire = memoire / contenu ListBox1.Add("/" & contenu & " " & comment) textBox2.Clear ENDIF
contenu = 0 signe = ope Transfert.comment = ""
CATCH Message.Info("Nombre invalide. Saisis un nombre valide") TextBox2.Clear signe = ope Transfert.comment = "" END ' -----------------------------------------------------------------------------
' **************************************************************************
PUBLIC SUB Button1_Click() chiffre(1) END
PUBLIC SUB Button2_Click() chiffre(2) END
PUBLIC SUB Button3_Click() chiffre(3) END
PUBLIC SUB Button4_Click() chiffre(4) END
PUBLIC SUB Button5_Click() chiffre(5) END
PUBLIC SUB Button6_Click() chiffre(6) END
PUBLIC SUB Button7_Click() chiffre(7) END
PUBLIC SUB Button8_Click() chiffre(8) END
PUBLIC SUB Button9_Click() chiffre(9) END
PUBLIC SUB Button0_Click() chiffre(0) END
PUBLIC SUB ButtonVir_Click() chiffre(",") END
PUBLIC SUB ButtonAdd_Click() TextBox1.Text = ("+") operation("+") END
PUBLIC SUB ButtonSoust_Click() TextBox1.Text = ("-") operation("-") END
PUBLIC SUB ButtonMult_Click() TextBox1.Text = ("x") operation("x") END
PUBLIC SUB ButtonDiv_Click() TextBox1.Text = ("/") operation("/") END
PUBLIC SUB ButtonEga_Click() TextBox1.Text = ("=") operation("+") ListBox1.Add("=" & memoire) ListBox1.Add("--------------") memoire = 0
END
PUBLIC SUB ButtonC_Click() ListBox1.Clear textBox2.Clear contenu = 0 memoire = 0 signe = "+" END
PUBLIC SUB ButtonOff_Click()
ME.close
END
PUBLIC SUB Button10_Click() Commentaire.Show
END
' ----------------------------- gestion pavé numerique clavier ------------------------ PUBLIC SUB Form_KeyPress()
DIM ltext AS VARIANT ltext = Key.Text
IF ltext = 0 THEN Button0_click IF ltext = 1 THEN Button1_click IF ltext = 2 THEN Button2_click IF ltext = 3 THEN Button3_click IF ltext = 4 THEN Button4_click IF ltext = 5 THEN Button5_click IF ltext = 6 THEN Button6_click IF ltext = 7 THEN Button7_click IF ltext = 8 THEN Button8_click IF ltext = 9 THEN Button9_click IF ltext = "+" THEN ButtonAdd_Click IF ltext = "-" THEN ButtonSoust_Click IF ltext = "/" THEN ButtonDiv_Click IF ltext = "*" THEN ButtonMult_Click IF ltext = "=" THEN ButtonEga_Click IF ltext = "." THEN ButtonVir_Click IF key.Code = key.Return OR key.Code = key.Enter THEN ButtonEga_Click IF key.code = Key.Esc THEN ButtonC_Click
END
'Ouvre un fichier texte pour afficher le calcul dans la listbox1 PUBLIC SUB ButtonOuvre_Click() Dialog.Title = "Choisis ton fichier" Dialog.Filter = ["*.txt", "fichiers texte", "*", "Tous"] IF Dialog.OpenFile() THEN RETURN ListBox1.List = Split(File.Load(Dialog.Path), "\n") CATCH Message.Info("Ouverture impossible:\n" & Dialog.Path & "\n" & Error.Text) END
' Sauvegarde le contenu de la listbox1 dans un fichier texte PUBLIC SUB ButtonSauve_Click() Dialog.Title = "Nomme ton fichier" Dialog.Filter = ["*.txt", "Fichiers texte", "*", "Tous"] IF Dialog.SaveFile() THEN RETURN File.Save(Dialog.Path, ListBox1.List.Join("\n")) CATCH Message.Info("Sauvegarde impossible:\n" & Dialog.Path & "\n" & Error.Text) END
PUBLIC SUB ListBox1_DblClick() CommentaireListe.Show() END
PUBLIC SUB ModifLigne() comment = Transfert.commentList ListBox1.Current.Text = ListBox1.text & " " & comment END
|