bonjour je commence tout juste en vb, j'essaye de faire un petit exo
un petit coup de main s'il vous plait
J'ai un bouton "remplir tableau"
et un autre "calculer somme"
lorsque l'on clique sur "remplir tableau" on voit tous les chiffres dans la fenetre texte et lorsque l'on clique sur calculer somme on yvoit le résultat
je fais une fonction avec une boucle for pour charger le tableau
et une autre qui calcule la somme des chiffres entrées dans le tableau
Voila le code
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 Private Sub CmdFermer_Click() End End Sub Private Sub cmdSomme_Click() Dim Resultat As Integer Dim tintTab As Integer Dim intCpt As Integer Resultat = Somme(tintTab(intCpt)) Me.txtResult.Text = Resultat End Sub Private Sub CmdTab_Click() Dim intCpt As Integer Dim tintTab(4) As Single Dim remp As Integer remp = Remplir(tintTab) End Sub Function Somme(pintope1 As Integer, pintope2 As Integer, pintope2 As Integer, pintope3 As Integer, pintope4 As Integer) As Integer Somme = pintope1 + pintope2 + pintope3 + pintope4 End Function Function Remplir() Dim intCpt As Integer Dim tintTab(4) As Single For intCpt = 1 To 4 tintTab(intCpt) = tintTab(intCpt) + 1 Next intCpt End Function
Partager