Des minutes en heures et minutes dans une txtbox

dePOI

XLDnaute Junior
Bonjour à tous

Dans une Usf j'ai 3 textbox qui recoivent des valeurs nombres:
- TxtPREPARATION
- TxtREPOS
- TxtCUISSON.
Dans le même Usf une quatrième textbox assure le total des 3 précédentes.
Elle est censée m'afficher ce total en heures et minutes.
Mais quoi que je modifie dans mon code :
'
'|***************************************************************************|
'| TROIS MODULES POUR CALCULER la somme de TxtTEMPSTOTAL |
'|***************************************************************************|
'
Private Sub TxtPRÉPARATION_AfterUpdate()
TxtTEMPSTOTAL.Value = Val(TxtPREPARATION.Value) + Val(TxtREPOS.Value) + Val(TxtCUISSON.Value)
End Sub
Private Sub TxtREPOS_AfterUpdate()
TxtTEMPSTOTAL.Value = Val(TxtPREPARATION.Value) + Val(TxtREPOS.Value) + Val(TxtCUISSON.Value)
End Sub
Private Sub TxtCUISSON_AfterUpdate()
TxtTEMPSTOTAL.Value = Val(TxtPREPARATION.Value) + Val(TxtREPOS.Value) + Val(TxtCUISSON.Value)
End Sub
'
'|***************************************************************************|
'| AFFICHE TxtTEMPSTOTAL en HEURES ET MINUTES |
'|***************************************************************************|
'
'Private Sub TxtTEMPSTOTAL_Change()
'Dim sH As String
'Dim sM As String
'sH = Str(Int([TxtTEMPSTOTAL] / 60))
'sM = Format$([TxtTEMPSTOTAL] Mod 60, "00")
'TxtTEMPSTOTAL.Value = (sH & "h " & sM & "min")
'End Sub
j'ai toujours un message d'erreur sur la ligne sH = Str(Int([TxtTEMPSTOTAL] / 60)).
Je n'ai pas pu tester la ligne suivante car mon projet s'arrête à ce stade.
Quelqu'un peut-t'il m'aider?
Merci d'avance.
 

mapomme

XLDnaute Barbatruc
Supporter XLD
Re : Des minutes en heures et minutes dans une txtbox

Bonsoir dePOI,

Pour le fun, un essai dans le fichier joint avec des ScrollBar.
VB:
Private Sub ScrollBar1_Change()
  TxtPREPARATION = Format(CDbl(ScrollBar1) / 1440#, "h"" h ""mm"" mn""")
  total
End Sub

Private Sub ScrollBar2_Change()
  TxtREPOS = Format(CDbl(ScrollBar2) / 1440#, "h"" h ""mm"" mn""")
  total
End Sub

Private Sub ScrollBar3_Change()
  TxtCUISSON = Format(CDbl(ScrollBar3) / 1440#, "h"" h ""mm"" mn""")
  total
End Sub

Sub total()
Dim HH As Double
  HH = ScrollBar1 + ScrollBar2 + ScrollBar3
  TxtTEMPSTOTAL = Int(HH / 60) & " h " & (HH Mod 60) & " mn"
End Sub
 

Pièces jointes

  • Des minutes en heures et minutes dans une txtbox v1.xlsm
    22.7 KB · Affichages: 38
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 249
Messages
2 086 598
Membres
103 253
dernier inscrit
alscanv974