Problème de soustraction d'heure et minute
Résolu
2015-1158
Messages postés
34
Date d'inscription
Statut
Membre
Dernière intervention
-
archer -
archer -
A voir également:
- Problème de soustraction d'heure et minute
- Changement d'heure - Guide
- Heure de connexion whatsapp qui ne changé pas - Accueil - WhatsApp
- Cdg heure d'arrivée a destination shein ✓ - Forum Consommation & Internet
- Sb7+ comment changer l'heure - Forum Accessoires & objets connectés
- Colis shein bloqué CDG - Forum Consommation & Internet
2 réponses
Bonjour,
Private Sub CalculPour() Dim hh As Integer Dim Mn As Integer Dim ss As Integer Dim t1 As Date Dim t2 As Date hh = 0 '?????????????????? Mn = 0 '????????????????????? ss = 0 '????????????????????????? If ComboBox1 <> "" And ComboBox2 <> "" Then t1 = ComboBox1.Value t2 = ComboBox2.Value TextBox1.Text = CalculDifferenceHeure(t1, t2) End If End Sub 'https://www.generation-nt.com/reponses/calculer-difference-entre-2-heures-entraide-2422711.html Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String 'HD Heure de début 'HF Heure de fin Dim Secondes As Long Dim Sec As String Dim Minutes As Long Dim Mn As String Dim Heures As Long Dim Hr As String Secondes = DateDiff("s", HD, HF) '* -1 a ajouter si t1 est toujours plus grand que t2 sinon temps negatif ....!!!! Heures = Secondes / 3600 Minutes = Secondes / 60 Mn = Minutes - (Heures * 60) Hr = Heures If Hr < 10 Then Hr = "0" & Heures If Mn < 10 Then Mn = "0" & Mn Sec = Secondes - (Minutes * 60) If Sec < 10 Then Sec = "0" & Sec CalculDifferenceHeure = Hr & ":" & Mn & ":" & Sec End Function
Bonjour
A voir aussi comme ca
A+
Maurice
A voir aussi comme ca
A+
Maurice
Dim Ctrl As Control Private Sub UserForm_Initialize() Me.Caption = "TACHES ??????" 'Me.BackColor = &H80000005 Me.PictureSizeMode = 1 He = 24 For Each Ctrl In Me.Controls Select Case Left(Ctrl.Name, 3) Case "Tex" Ctrl.BackColor = &H80000018 Ctrl.Font.Name = "Arial Narrow" Ctrl.Font.Size = 14 Ctrl.Font.Bold = True Ctrl.Height = He Ctrl.Tag = "O" Case "Com" Ctrl.BackColor = &H80000005 Ctrl.BackStyle = 0 Ctrl.Font.Name = "Arial Narrow" Ctrl.Font.Size = 14 Ctrl.Font.Bold = True End Select Next Ctrl End Sub Private Sub UserForm_Activate() Dim I&, J& 'je boucle sur les heures For I = 0 To 23 'je boucle sur les minutes par tranche de 30mn For J = 0 To 59 Step 30 'j'initialize ma combo ComboBox1.AddItem Format(I, "00") & ":" & Format(J, "00") Next Next End Sub Sub ComboBox1_Change() Dim I& ComboBox2.Clear For I = 0 To ComboBox1.ListCount - 1 If ComboBox1.Value < ComboBox1.List(I) Then ComboBox2.AddItem ComboBox1.List(I) End If Next I End Sub Sub ComboBox2_Change() Dim H1 As Date Dim H2 As Date H1 = CDate(ComboBox1.Value) H2 = CDate(ComboBox2.Value) 'TextBox1.Value = Format(H1 + H2, "hh:mm") TextBox1.Value = Format(H2 - H1, "hh:mm") End Sub