paf24
Messages postés20Date d'inscriptionmardi 25 février 2003StatutMembreDernière intervention12 janvier 2005
-
19 juin 2003 à 09:34
paf24
Messages postés20Date d'inscriptionmardi 25 février 2003StatutMembreDernière intervention12 janvier 2005
-
19 juin 2003 à 09:34
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
paf24
Messages postés20Date d'inscriptionmardi 25 février 2003StatutMembreDernière intervention12 janvier 2005 19 juin 2003 à 09:34
en effet çà foire quand y'a moins d'une heure, mais en plus, tes secondes sont en fait des dizième de secondes, tes minutes des secondes ...(flagrant en testant)
j'ai modifier un peu ton code et c'est bon :
Option Explicit
'declaration des variable'
'petite explication: la variable s veut dire seconde,h heure , m minute'
'la variable fin sert a arreter le timer'
'la varible s2,m2,h2 = disaine de seconde , minute , heure'
Dim s
Dim m
Dim h
Dim fin
Dim m2, s2, h2
Private Sub form_load()
'initialisation du système'
Timer1.Interval = 1000
Timer1.Enabled = False
h = 0
m = 0
s = 0
Private Sub Command1_Click()
'verification qu'il y a du temp a décompter'
'si le temp est a 0,arret'
'bon là c'est clair mais quand tu auras des progs de 1000 lignes, faudra mieux imbriquer les If au lieu de mettre des sauts (du moins c'est mon prof d'info qui le dit !)
If Label1.Caption = 0 Then: GoTo suite1: Else: GoTo start
suite1:
If Label3.Caption = 0 Then: GoTo suite2: Else: GoTo start
suite2:
If Label5.Caption = 0 Then: GoTo suite3: Else: GoTo start
suite3:
MsgBox "debut trop bas": Beep: GoTo fini
start:
Timer1.Enabled = True
Exit Sub
fini:
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False 'arret du timer'
End Sub
Private Sub Command3_Click()
End 'command quitter'
End Sub
Private Sub Command4_Click()
'changement du temp si click sur le bouton changer le temp'
h scrol1.Value: Bar3.Value scrol1.Value: Label1.Caption = scrol1.Value
m scrol2.Value: Bar2.Value scrol2.Value: Label3.Caption = scrol2.Value
s scrol3.Value: Bar1.Value scrol3.Value: Label5.Caption = scrol3.Value
If scrol1.Value < 10 Then: Label1.Caption 0 & scrol1.Value: Else: Label1.Caption scrol1.Value
If scrol2.Value < 10 Then: Label3.Caption 0 & scrol2.Value: Else: Label3.Caption scrol2.Value
If scrol3.Value < 10 Then: Label5.Caption 0 & scrol3.Value: Else: Label5.Caption scrol3.Value
End Sub
Private Sub scrol1_Change()
Label17.Caption = scrol1.Value
If scrol1.Value < 10 Then: Label17.Caption "0" & scrol1.Value: Else: Label17.Caption scrol1.Value
End Sub
Private Sub scrol2_Change()
Label18.Caption = scrol2.Value
If scrol2.Value < 10 Then: Label18.Caption "0" & scrol2.Value: Else: Label18.Caption scrol2.Value
End Sub
Private Sub scrol3_Change()
Label19.Caption = scrol3.Value
If scrol3.Value < 10 Then: Label19.Caption "0" & scrol3.Value: Else: Label19.Caption scrol3.Value
End Sub
Private Sub timer1_timer()
'decompte'
Bar1.Value = s
Bar2.Value = m
Bar3.Value = h
If s < 1 Then: s 59: m m - 1: Else: s = s - 1:
If s < 10 Then: s2 "0" & s: Else: s2 s
'voilà j'ai viré les jumps et mis une condition, maintenant çà marche pour n'importe quel interval de temps
If m < 1 And h <> 0 Then
m = 59
h = h - 1
End If
If m < 10 Then: m2 "0" & m: Else: m2 m
If h < 10 Then: h2 "0" & h: Else: h2 h
Label5.Caption = s2
Label3.Caption = m2
Label1.Caption = h2
Call test
End Sub
Private Sub test()
' si le temp arrive a 0 , arret du timer'
If h = 0 Then: GoTo suite: Else: Exit Sub
suite:
If m = 0 Then: GoTo suite2: Else: Exit Sub
suite2:
If s 0 Then: Timer1.Enabled False: Bar1.Value = 0: MsgBox "dring": Else: Exit Sub
Bar1.Value = 0
19 juin 2003 à 09:34
j'ai modifier un peu ton code et c'est bon :
Option Explicit
'declaration des variable'
'petite explication: la variable s veut dire seconde,h heure , m minute'
'la variable fin sert a arreter le timer'
'la varible s2,m2,h2 = disaine de seconde , minute , heure'
Dim s
Dim m
Dim h
Dim fin
Dim m2, s2, h2
Private Sub form_load()
'initialisation du système'
Timer1.Interval = 1000
Timer1.Enabled = False
h = 0
m = 0
s = 0
m2 = "0" & m
h2 = "0" & h
s2 = "0" & s
Label1.Caption = h2
Label3.Caption = m2
Label5.Caption = s2
End Sub
Private Sub Command1_Click()
'verification qu'il y a du temp a décompter'
'si le temp est a 0,arret'
'bon là c'est clair mais quand tu auras des progs de 1000 lignes, faudra mieux imbriquer les If au lieu de mettre des sauts (du moins c'est mon prof d'info qui le dit !)
If Label1.Caption = 0 Then: GoTo suite1: Else: GoTo start
suite1:
If Label3.Caption = 0 Then: GoTo suite2: Else: GoTo start
suite2:
If Label5.Caption = 0 Then: GoTo suite3: Else: GoTo start
suite3:
MsgBox "debut trop bas": Beep: GoTo fini
start:
Timer1.Enabled = True
Exit Sub
fini:
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False 'arret du timer'
End Sub
Private Sub Command3_Click()
End 'command quitter'
End Sub
Private Sub Command4_Click()
'changement du temp si click sur le bouton changer le temp'
h scrol1.Value: Bar3.Value scrol1.Value: Label1.Caption = scrol1.Value
m scrol2.Value: Bar2.Value scrol2.Value: Label3.Caption = scrol2.Value
s scrol3.Value: Bar1.Value scrol3.Value: Label5.Caption = scrol3.Value
If scrol1.Value < 10 Then: Label1.Caption 0 & scrol1.Value: Else: Label1.Caption scrol1.Value
If scrol2.Value < 10 Then: Label3.Caption 0 & scrol2.Value: Else: Label3.Caption scrol2.Value
If scrol3.Value < 10 Then: Label5.Caption 0 & scrol3.Value: Else: Label5.Caption scrol3.Value
End Sub
Private Sub scrol1_Change()
Label17.Caption = scrol1.Value
If scrol1.Value < 10 Then: Label17.Caption "0" & scrol1.Value: Else: Label17.Caption scrol1.Value
End Sub
Private Sub scrol2_Change()
Label18.Caption = scrol2.Value
If scrol2.Value < 10 Then: Label18.Caption "0" & scrol2.Value: Else: Label18.Caption scrol2.Value
End Sub
Private Sub scrol3_Change()
Label19.Caption = scrol3.Value
If scrol3.Value < 10 Then: Label19.Caption "0" & scrol3.Value: Else: Label19.Caption scrol3.Value
End Sub
Private Sub timer1_timer()
'decompte'
Bar1.Value = s
Bar2.Value = m
Bar3.Value = h
If s < 1 Then: s 59: m m - 1: Else: s = s - 1:
If s < 10 Then: s2 "0" & s: Else: s2 s
'voilà j'ai viré les jumps et mis une condition, maintenant çà marche pour n'importe quel interval de temps
If m < 1 And h <> 0 Then
m = 59
h = h - 1
End If
If m < 10 Then: m2 "0" & m: Else: m2 m
If h < 10 Then: h2 "0" & h: Else: h2 h
Label5.Caption = s2
Label3.Caption = m2
Label1.Caption = h2
Call test
End Sub
Private Sub test()
' si le temp arrive a 0 , arret du timer'
If h = 0 Then: GoTo suite: Else: Exit Sub
suite:
If m = 0 Then: GoTo suite2: Else: Exit Sub
suite2:
If s 0 Then: Timer1.Enabled False: Bar1.Value = 0: MsgBox "dring": Else: Exit Sub
Bar1.Value = 0
End Sub