Dim secondes As Integer = 4321 Dim temps As TimeSpan = TimeSpan.FromSeconds(secondes) Dim hhmmss As String = temps.ToString() Dim hhmm As String = temps.ToString("hh\:mm")
Public Class Form1
Dim TempsTotal As Long 'TempsTotal est le temps en secondes
Dim Heures As Integer
Dim Minutes As Integer
Dim Secondes As Integer
Sub Conversion(TempsTotal)
TempsTotal = Txt_seconde.Text
Heures = Int(TempsTotal / 3600)
Minutes = Int((TempsTotal - 3600 * Heures) / 60)
Secondes = TempsTotal - 3600 * Heures - 60 * Minutes
Label1.Text = Format(Str(Heures + ":" + Minutes + ":" + Secondes))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Conversion(TempsTotal)
End Sub
End Class
Option Strict On Public Class Form1 Dim Temps As Long 'TempsTotal est le temps en secondes Dim Heures As Integer Dim Minutes As Integer Dim Secondes As Integer Sub Conversion(ByVal TempsTotal As Long) Heures = CInt(Int(TempsTotal / 3600)) Minutes = CInt(Int((TempsTotal - 3600 * Heures) / 60)) Secondes = CInt(TempsTotal - 3600 * Heures - 60 * Minutes) Label1.Text = (Format(Heures & ":" & Minutes & ":" & Secondes)) 'là, on a le temps formaté hh:mm:ss 'Format sert à afficher 2 chiffres pour les heures, les minutes et les secondes 'Exemple: avec Format: 08:05:23 ' sans Format: 8:5:23 End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Temps = 12500 Conversion(Temps) End Sub End Class
4 sept. 2018 à 19:06
11 sept. 2018 à 13:56
Top !
11 sept. 2018 à 17:34