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
| Private Sub MSHFlexGrid1_Click()
Text1.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0) 'Num
Text2.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 1) 'Nom
Text3.Text = MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 2) 'Phone
Text10.Text = ""
'Text4.Text = "": Text5.Text = "": Text6.Text = ""
'Text7.Text = "": Text8.Text = "": Text9.Text = ""
Dim T As Integer, Total As Single, TempRs As New ADODB.Recordset
ListTypeFaute.Clear: ListValeur.Clear 'vide les ListBox
'récuperation de tous les enregistrement du "Nom"
TempRs.Open "Select * From Grille Where Nom = '" & Text2.Text & "' Order By Num ASC", db, adOpenStatic, adLockPessimistic
If TempRs.State = adStateClosed Then MsgBox "Recordset fermé": Exit Sub
If TempRs.EOF Then MsgBox "Recordset vide": Exit Sub
'boucle sur le(s) enregistrement(s)
For T = 1 To TempRs.RecordCount
ListTypeFaute.AddItem TempRs![Faute]
ListValeur.AddItem FormatStr(TempRs![Valeur]) ' ajout à la liste en formatant pour mettre les chiffres alignés à droite
'petit bidouillage pour permettre le calcul avec séparateur décimal VIRGULE est non pas POINT
Total = Total + CSng(Replace(TempRs![Valeur], ".", ",")) ' totalise, par cumul, les "VALEUR"
TempRs.MoveNext ' avence à l'enregistrement suivant
Next T
TempRs.Close: Set TempRs = Nothing 'nettoyage
Text10.Text = Total 'affichage de la somme des VALEUR FAUTE
End Sub
Function FormatStr(Valeur) As String
FormatStr = CStr(Valeur)
FormatStr = Format(FormatStr, ".00")
FormatStr = Replace(FormatStr, ",", ".")
FormatStr = String(14 - Len(FormatStr), " ") & FormatStr
End Function |
Partager