Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim sTime As String = "00:18:00" Dim tsTime As TimeSpan = DateTime.Parse(sTime).TimeOfDay Dim dTime As Double = (tsTime.Seconds + (tsTime.Minutes * 60) + (tsTime.Hours * 3600)) * 4.24264069 Dim tsRes As TimeSpan = DateTime.FromOADate(dTime).TimeOfDay MessageBox.Show(String.Format("{0}:{1}:{2}", tsRes.Hours, tsRes.Minutes, Convert.ToInt16(tsRes.Seconds))) End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sTime As String = "00:18:00" Dim tsTime As TimeSpan = DateTime.Parse(sTime).TimeOfDay Dim dTime As Double = (tsTime.Seconds + (tsTime.Minutes * 60) + (tsTime.Hours * 3600)) * 4.24264069 Dim tsRes As TimeSpan = DateTime.FromOADate(dTime).TimeOfDay Dim nbsecondes As Integer Dim nbjours As Integer Dim nbheures As Integer Dim nbminutes As Integer nbsecondes = dTime nbjours = nbsecondes \ 86400 nbheures = (nbsecondes Mod 86400) \ 3600 nbminutes = (nbsecondes Mod 3600) \ 60 nbsecondes = (nbsecondes Mod 3600) Mod 60 MsgBox(nbjours & " jours " & nbheures & " heures " & nbminutes & _ " minutes" & nbsecondes & " secondes ") End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim dteDate As DateTime dteDate = DateTime.FromOADate(CDate(TextBox1.Text).ToOADate * 4.24264069)
repasser ta durée en nombre de secondes,
le multiplier par ton coefficient
MsgBox CDate(CDate("06:18:00") * 4.24264069)
Dim dIn As Date Dim dOut As New Date dIn = Date.Parse("00:18:00") dOut = dOut.AddSeconds((dIn.Hour * 3600 + dIn.Minute * 60 + dIn.Second) * 4.24264069) MessageBox.Show(dOut.ToString("hh:mm:ss"))
MessageBox.Show(String.Format("{0:00}:{1:00}:{2:00}", tsRes.Hours, tsRes.Minutes, Convert.ToInt16(tsRes.Seconds)))
« par contre j'obtiens 1:14:48 (avec l'arrondi des secondes) »dixit PCPT
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim tsTime As TimeSpan = DateTime.Parse("00:18:00").TimeOfDay Dim dTime As Double = (tsTime.Seconds + (tsTime.Minutes * 60) + (tsTime.Hours * 3600)) * 4.24264069 MessageBox.Show(String.Format("{0:00}:{1:00}:{2:00}", Convert.ToInt32(dTime) \ 3600, Convert.ToInt32(dTime Mod 3600) \ 60, Convert.ToInt32(dTime Mod 3600) Mod 60)) End Sub