hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006
-
7 sept. 2005 à 18:36
hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006
-
8 sept. 2005 à 21:07
Bonjour.
Je n'arrive pas à faire marcher ma fonction de compte à rebours dont le code suit.
Public Function makeCountdown(Cd As Integer, Ch As Integer, Cm As Integer, Cs As Integer, lblCDays As Label, lblCHours As Label, lblCMinutes As Label, lblCSeconds As Label)
If Cs = 0 Then
If Ch > 0 And Cm = 0 Then
lblCSeconds = "59"
lblCMinutes = "59"
Ch = Ch - 1
lblCHours.Caption = Ch
Else
lblCSeconds = "59"
Cm = Cm - 1
lblCMinutes.Caption = Cm
End If
Else
Cs = Cs - 1
lblCSeconds.Caption = Cs
End If
End Function
En fait cette fonction gère donc pour l'instant que 4 des 3 labels. Il y a un label pour chaque type. Jours Heures Minutes et Secondes.
Quand j'introduis 4h dans le temps sélectionné je reçois chronologiquement:
4 h 0m 0s - état initial
3h 59m 59s -phase 1
2h 59m 59s -phase 2
1h 59m 59s -phase 3
0h 59m 59s -phase 4
-1h 59m 59s -phase 5
ect.
Désolé si c'est vraiment très con comme question...
Hurt 14
Paladin2107
Messages postés154Date d'inscriptionsamedi 25 octobre 2003StatutMembreDernière intervention 5 septembre 20081 7 sept. 2005 à 18:51
C'est fait vite fait j'avou mais bon c'est deja sa. tu as l'a démarche
Tu peux en faire une fonction
Place dans un timer
pour faire une compteur qui decremante
Dim i As Integer
Dim j As Integer
Dim h As Integer
Dim e As Integer
Dim f As Integer
Dim b As Integer
i = 0
If txtS.Text <> 0 And i < 10 Then
txtS.Text = txtS.Text - 1
i = i + 1
Else
txtS.Text = "9"
i = 0
j = 0
If txtSS.Text <> 0 And j < 6 Then
txtSS.Text = txtSS.Text - 1
j = j + 1
Else
txtSS.Text = "5"
h = 0
j = 0
If txtM.Text <> 0 And h < 10 Then
txtM.Text = txtM.Text - 1
h = h + 1
Else
txtM.Text = "9"
h = 0
e = 0
If txtMM.Text <> 0 And e < 6 Then
txtMM.Text = txtMM.Text - 1
e = e + 1
Else
txtMM.Text = "5"
e = 0
f = 0
If txtH.Text <> 0 And f < 3 Then
txtH.Text = txtH.Text - 1
f = f + 1
Else
txtH.Text = "3"
f = 0
b = 0
If txtHH.Text <> 0 And b < 2 Then
txtHH.Text = txtHH.Text - 1
b = b + 1
Else
txtHH.Text = "0"
End If
End If
End If
End If
End If
End If
hurt14
Messages postés33Date d'inscriptionvendredi 2 janvier 2004StatutMembreDernière intervention11 août 2006 7 sept. 2005 à 18:56
Ouais je vois comment t'as fait, j'avais trouvé cette methode sur une source mais je voulais essayer de gérer un label en entier et non pas chiffre par chiffre. T'aurais pas une idée ?
Entre-temps merci
Mikaels35
Messages postés146Date d'inscriptiondimanche 23 janvier 2005StatutMembreDernière intervention17 novembre 20092 8 sept. 2005 à 07:47
Salut
Je verrais bien un truc dans ce genre:
Cs = Cs - 1
If Cs < 0 Then
Cs = 59
Cm = Cm - 1
If Cm < 0 Then
Cm = 59
Ch = Ch - 1
End If
End If
LblCH = Format(Ch,"00")
LblCM =Format(Cm,"00")
LblCS = Format(Cs,"00")
Tu rajoutes ce qu'il faut pour gérer les jours dans le même style !
@+
Vous n’avez pas trouvé la réponse que vous recherchez ?
Mikaels35
Messages postés146Date d'inscriptiondimanche 23 janvier 2005StatutMembreDernière intervention17 novembre 20092 8 sept. 2005 à 09:56
Si tu veux travailler sur les Labels uniquement:
'Initialise les labelsLblCH "04": LblCM "00": LblCS = "00"
Private Sub CountDown(ByRef H As Label, ByRef M As Label, ByRef S As Label)
S= Format(S - 1, "00")
If S < 0 Then
S = "59"
M = Format(M - 1, "00")
If M < 0 Then
M = "59"
H = Format(H - 1, "00")
End If
End If
End Sub
'Appel de la Sub par un Timer de 1s par exemple
Private Sub Timer1_Timer()
Call CountDown(LblCH, LblCM, LblCS)
End Sub