adrienr11vdv
Messages postés99Date d'inscriptionjeudi 13 juillet 2006StatutMembreDernière intervention16 avril 2009
-
4 oct. 2006 à 14:45
Vb Lover
Messages postés221Date d'inscriptionvendredi 30 novembre 2001StatutMembreDernière intervention13 février 2010
-
5 oct. 2006 à 10:12
voici le tableau des notes et des coefficients (note et coeff):
12 2
11 1
19 2
8 4
14 1
le but serai de faire d'abord une moyenne par coefficient puis on calculerai la moyenne final.
en fait, on aurai:
(((12+19)/2)*2+((11+14)/2)*1+8*4)/(2+1+4)
pour faire cela, j'ai rangé les notes par coefficients
11 1
14 1
12 2
19 2
8 4
ensuite j'ai essayé de faire le calcul de la moyenne mais il me met l'erreur imcompatibilité de type.
voici le code pour ranger les notes suivant le coefficient, ce code a l'air de marché.
If txt_note <> "" Then
tmoy(ar).note = CInt(txt_note.Text)
tmoy(ar).coef = CInt(txt_coeff.Text)
ar = ar + 1
End If
num = ar
z = 0
Do While z <> num
k = z + 1
l = z + 1
Do While k <> num + 1
k = k + 1
If tmoy(k).coef < tmoy(l).coef Then
l = k
End If
Loop
var = tmoy(z + 1).coef
tmoy(z + 1).coef = tmoy(l).coef
tmoy(l).coef = var
varn = tmoy(z + 1).note
tmoy(z + 1).note = tmoy(l).note
tmoy(l).note = varn
z = z + 1
Loop
voici le code qui me permet de calculer la moyenne mais il y a un problème
'essai petite moyenne
Do While tmoy(p).coef <> ""
search = tmoy(p).coef
Do While tmoy(p).coef = search
no = no + tmoy(p).note
nb = nb + 1
p = p + 1
Loop
mo = no / nb
tmoyg(m).moyenne = mo
tmoyg(m).nb = nb
m = m + 1
Loop
For m = 1 To p
nos = tmoyg(m).moyenne
nomb = tmoyg(m).nb
moyterm = moyterm + (nos * nomb)
moynomb = moynomb + nomb
Next
moyfinal = moyterm / moynomb
txt_dagl.Text = moyfinal
si quelqu'un aurai une solution à mon problème ou si quelqu'un voit une autre solution, j'aimerai qu'il me fasse parvenir ces solutions.
je vous remercie d'avance
coordialement
adrien
A voir également:
Calculatrice de moyenne avec coefficient
Calcul des notes du bac - Meilleures réponses
Calculatrice moyenne avec coefficient - Meilleures réponses
alosamoelle
Messages postés129Date d'inscriptionjeudi 28 octobre 2004StatutMembreDernière intervention23 mai 20091 5 oct. 2006 à 09:45
voila j'ai mis 5 textbox pour les notes et 5 pour les coef
il n'est fait que pour 5 notes mais tu peux adapter (et oui je ne fais pas tout le boulot lol) et l'ameliorer car je viens de le faire vite fait
je trouve 12 pour ta moyenne en tout, si tu as des questions n'hesite pas
Dim notecoef1(5) ' note avec coef 1
Dim notecoef2(5) 'note avec coef 2
Dim notecoef4(5) ' note avec coef 4
' met les notes suivant le coef
For a = 0 To 4If txt_coeff(a) 1 Then notecoef1(a) txt_note(a)If txt_coeff(a) 2 Then notecoef2(a) txt_note(a)If txt_coeff(a) 4 Then notecoef4(a) txt_note(a)
Next
' calcul moyenne avec coef
Dim moycoef1
Dim moycoef2
Dim moycoef4
Dim ancien
Dim n1
Dim n2
Dim n4
' calcul moy coef 1
n1 = 0
For a = 0 To 4
ancien = moycoef1
If notecoef1(a) <> "" Then
: moycoef1 = CInt(notecoef1(a) + ancien)
: n1 = n1 + 1
End If
Next
moycoef1 = CInt(moycoef1)
' calcul moy coef 2
n2 = 0
ancien = ""
For a = 0 To 4
ancien = moycoef2
If notecoef2(a) <> "" Then
: moycoef2 = CInt(notecoef2(a) + ancien)
: n2 = n2 + 2
End If
Next
moycoef2 = CInt((moycoef2) * 2)
' calcul moy coef 4
n4 = 0
ancien = ""
For a = 0 To 4
ancien = moycoef4
If notecoef4(a) <> "" Then
: moycoef4 = CInt(notecoef4(a) + ancien)
: n4 = n4 + 4
End If
Next
moycoef4 = CInt((moycoef4) * 4)
Vb Lover
Messages postés221Date d'inscriptionvendredi 30 novembre 2001StatutMembreDernière intervention13 février 20105 5 oct. 2006 à 10:12
bon, je vois pas vraiment l'intérêt de se compliquer la vie comme ça si
le but est simplement d'avoir la moyenne finale pondérée... tu renommes
tes variables comme tu veux, et moi je considère que tu as n notes
appelées note(i) avec les coefficients correspondants coef(i), et ça
donne: