XL 2013 [Résolu] Format minutes et secondes dans textbox

Lone-wolf

XLDnaute Barbatruc
Bonjour à toutes et à tous :)

D'après cet exemple:


DebCom = 12:01:08
FinCom = 12: 01:48
Duree = (FinCom - DebCom)
TextBox8 = Format(Duree, "mm:ss")

Comment obtenir 00:40 si inférieur à 1 minute?
 
Dernière édition:

job75

XLDnaute Barbatruc
Bonjour Lonewolf, Bernard,

L'ennui avec "mm:ss" c'est qu'on ne sait plus s'il s'agit de "mm:ss" ou de "hh:mm".

Avec ceci aucun problème :
Code:
DebCom = TimeValue("12:01:08")
FinCom = TimeValue("12:01:48")
TextBox8 = Format(FinCom - DebCom, "hh:mm:ss")
A+
 

Lone-wolf

XLDnaute Barbatruc
Bonjour Dranreb :)

Merci Shöne ;). C'est parfait.

Edit : bonjour Gerard :). En réalité c'est avec des textbox's. Et d'après l'exemple de Dranreb

VB:
Private Sub Image1_Click()  'Fin communication

TextBox7 = Format(Time, "hh:mm:ss")
DebCom = TimeValue(TextBox6)
FinCom = TimeValue(TextBox7)
Duree = Format(FinCom - DebCom, "hh:mm:ss")
TextBox8 = Mid$(Duree, 4)
End Sub

Et ça me donne bien 00:40 sec.
 

job75

XLDnaute Barbatruc
Re,

Maintenant si l'on tient au format "mm:ss" il est bon de prévoir le cas des minutes >= 60 :
Code:
DebCom = TimeValue("12:01:08")
FinCom = TimeValue("14:01:48")
Duree = FinCom - DebCom
TextBox8 = Format(Int(1440 * Duree), "00") & Format(Second(Duree), "\:00")
A+
 

Discussions similaires

Statistiques des forums

Discussions
312 166
Messages
2 085 885
Membres
103 018
dernier inscrit
mohcen23