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
| ' Gambas class file
PRIVATE lbl AS NEW Label[] PRIVATE btn AS NEW Button[] PRIVATE tbx AS NEW TextBox[]
PUBLIC SUB _new()
END
PUBLIC SUB Form_Open() DIM i, IDlbl, IDbtn AS INTEGER WITH ME .H = 152 .W = 288 .Resizable = FALSE .Center .Title = Application.Title & " Version " & Application.Version END WITH FOR i = 0 TO 3 lbl.Add(NULL, lbl.Count) lbl[i] = NEW Label(ME) 'As "GrLblInfos" IDlbl = lbl.Count - 1 WITH lbl[i] .Alignment = 3 .Visible = FALSE END WITH NEXT 'i WITH lbl[0] .Move(16, 16, 144, 24) .Visible = TRUE .Caption = ("Entrer un mot...") END WITH WITH lbl[1] .Move(160, 16, 128, 24) .Caption = ("Poids du mot") END WITH lbl[2].Move(160, 40, 128, 24) lbl[3].Move(88, 72, 192, 24) FOR i = 0 TO 2 IDbtn = btn.Count btn.Add(NULL, btn.Count) btn[IDbtn] = NEW Button(ME) AS "GrBtn" btn[i].Tag = IDbtn SELECT i CASE 0 btn[i].Move(192, 112, 80, 32) btn[i].Caption = ("Quitter") CASE 1 btn[i].Move(104, 112, 72, 32) btn[i].Caption = ("Calculer") CASE 2 btn[i].Move(8, 112, 80, 32) btn[i].Caption = ("Effacer") END SELECT NEXT 'i tbx.Add(NULL, tbx.Count) tbx[0] = NEW TextBox(ME) AS "Tbx" WITH tbx[0] .MaxLength = 10 'nbr de caractère maximum autorisé .Alignment = 3 .Move(16, 40, 144, 24) .SetFocus END WITH END
PUBLIC SUB GrBtn_Click() DIM i, j, k AS INTEGER SELECT LAST.Tag CASE 0 'bouton Quitter ME.Close CASE 1 'bouton Calculer j = Len(tbx[0].Text) 'j est le nombre de lettres du tbx[0] lbl[3].Caption = ("Mot composé de " 'début de la phrase... IF j < 2 THEN 'si j est inférieur à 2 on ne mettra pas de 's' à lettre i = Asc(tbx[0].Text) 'i est la valeur ASCII de la lettre contenue dans tbx[0] lbl[3].Caption = lbl[3].Caption & j & (" lettre.") 'affiche que le mot est composé de 1 ou 0 lettre ELSE FOR k = j TO 1 STEP -1 i = i + Asc(tbx[0].Text, k) 'comptabilise la valeur ASCII de toutes les lettres NEXT 'k lbl[3].Caption = lbl[3].Caption & j & (" lettres.") 'affiche que le mot est composé de j lettres ENDIF lbl[2].Caption = i 'indique le poids du mot FOR i = 1 TO 3 lbl[i].Visible = TRUE NEXT 'i CASE 2 'bouton Effacer FOR i = 1 TO 3 lbl[i].Visible = FALSE NEXT 'i tbx[0].Text = "" tbx[0].SetFocus END SELECT END
PUBLIC SUB Tbx_Change() tbx[0].Text = UCase$(tbx[0].Text) END
|