Voici ma solution pour ceux que sa peut-être utile
Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String 'HD Heure de début 'HF Heure de fin
Dim Secondes As Long Dim Sec As String Dim Minutes As Long Dim Mn As String Dim Heures As Long Dim Hr As String If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit Function
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
Voici ma solution pour ceux que sa peut-être utile
Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String
'HD Heure de début
'HF Heure de fin
Dim Secondes As Long
Dim Sec As String
Dim Minutes As Long
Dim Mn As String
Dim Heures As Long
Dim Hr As String
If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit
Function
Voici ma solution pour ceux que sa peut-être utile
Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String 'HD Heure de début 'HF Heure de fin
Dim Secondes As Long Dim Sec As String Dim Minutes As Long Dim Mn As String Dim Heures As Long Dim Hr As String If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit Function
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
Zoury
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton traitement... :O/
Voici ma version de la même fonction si tu veux comparer.. '*** Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As String Dim l As Long l = DateDiff("s", dt1, dt2) DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _ Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _ Right$("00" & CStr(l Mod 60), 2) End Function '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/ http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/ "Yves" wrote in message news: : Voici ma solution pour ceux que sa peut-être utile : : Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String : 'HD Heure de début : 'HF Heure de fin : : Dim Secondes As Long : Dim Sec As String : Dim Minutes As Long : Dim Mn As String : Dim Heures As Long : Dim Hr As String : If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit : Function : : Secondes = DateDiff("s", HD, HF) : : Heures = Secondes 3600 : Minutes = Secondes 60 : : Mn = Minutes - (Heures * 60) : Hr = Heures : : If Hr < 10 Then : Hr = "0" & Heures : End If : : If Mn < 10 Then : Mn = "0" & Mn : End If : : Sec = Secondes - (Minutes * 60) : : If Sec < 10 Then : Sec = "0" & Sec : End If : : CalculDifferenceHeure = Hr & ":" & Mn & ":" & Sec : : End Function : : : : -- : -- : Cordialement : Yves : : Programmeur/Analyste : _________________________________________ : : : La FAQ VB : http://faq.vb.free.fr : : API-Guide, indispensable pour les APIs : http://www.allapi.net/agnet/apiguide.shtml : : Mz-Tools, add-in pour VB : http://www.mztools.com/ : :
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton traitement...
:O/
Voici ma version de la même fonction si tu veux comparer..
'***
Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As String
Dim l As Long
l = DateDiff("s", dt1, dt2)
DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _
Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _
Right$("00" & CStr(l Mod 60), 2)
End Function
'***
--
Cordialement
Yanick Lefebvre - MVP pour Visual Basic
http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/
http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/
"Yves" <cpsqinfo@globetrotter.qc.ca> wrote in message
news:uqpOe98RDHA.2676@TK2MSFTNGP10.phx.gbl...
: Voici ma solution pour ceux que sa peut-être utile
:
: Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String
: 'HD Heure de début
: 'HF Heure de fin
:
: Dim Secondes As Long
: Dim Sec As String
: Dim Minutes As Long
: Dim Mn As String
: Dim Heures As Long
: Dim Hr As String
: If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit
: Function
:
: Secondes = DateDiff("s", HD, HF)
:
: Heures = Secondes 3600
: Minutes = Secondes 60
:
: Mn = Minutes - (Heures * 60)
: Hr = Heures
:
: If Hr < 10 Then
: Hr = "0" & Heures
: End If
:
: If Mn < 10 Then
: Mn = "0" & Mn
: End If
:
: Sec = Secondes - (Minutes * 60)
:
: If Sec < 10 Then
: Sec = "0" & Sec
: End If
:
: CalculDifferenceHeure = Hr & ":" & Mn & ":" & Sec
:
: End Function
:
:
:
: --
: --
: Cordialement
: Yves
:
: Programmeur/Analyste
: _________________________________________
:
:
: La FAQ VB
: http://faq.vb.free.fr
:
: API-Guide, indispensable pour les APIs
: http://www.allapi.net/agnet/apiguide.shtml
:
: Mz-Tools, add-in pour VB
: http://www.mztools.com/
:
:
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton traitement... :O/
Voici ma version de la même fonction si tu veux comparer.. '*** Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As String Dim l As Long l = DateDiff("s", dt1, dt2) DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _ Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _ Right$("00" & CStr(l Mod 60), 2) End Function '***
-- Cordialement Yanick Lefebvre - MVP pour Visual Basic http://faq.vb.free.fr/?rubrique=0 - http://www.mvps.org/vbnet/ http://www.mentalis.org/agnet/apiguide.shtml - http://www.mztools.com/ "Yves" wrote in message news: : Voici ma solution pour ceux que sa peut-être utile : : Function CalculDifferenceHeure(HD As Variant, HF As Variant) As String : 'HD Heure de début : 'HF Heure de fin : : Dim Secondes As Long : Dim Sec As String : Dim Minutes As Long : Dim Mn As String : Dim Heures As Long : Dim Hr As String : If IsNull(HD) Or IsNull(HF) Then CalculDifferenceHeure = "00:00:00": Exit : Function : : Secondes = DateDiff("s", HD, HF) : : Heures = Secondes 3600 : Minutes = Secondes 60 : : Mn = Minutes - (Heures * 60) : Hr = Heures : : If Hr < 10 Then : Hr = "0" & Heures : End If : : If Mn < 10 Then : Mn = "0" & Mn : End If : : Sec = Secondes - (Minutes * 60) : : If Sec < 10 Then : Sec = "0" & Sec : End If : : CalculDifferenceHeure = Hr & ":" & Mn & ":" & Sec : : End Function : : : : -- : -- : Cordialement : Yves : : Programmeur/Analyste : _________________________________________ : : : La FAQ VB : http://faq.vb.free.fr : : API-Guide, indispensable pour les APIs : http://www.allapi.net/agnet/apiguide.shtml : : Mz-Tools, add-in pour VB : http://www.mztools.com/ : :
Philippe ILLINGER
Bonjour,
"Zoury" wrote in message news:%
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton
traitement...
:O/
Voici ma version de la même fonction si tu veux comparer.. '*** Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As
String
Dim l As Long l = DateDiff("s", dt1, dt2) DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _ Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _ Right$("00" & CStr(l Mod 60), 2) End Function '***
Cela me parait bien complique !!! Et Pourquoi pas directement...?
DateTimeDiff = dt1 - dt2 ?
avec un type date en retour evidemment..
Best Regards
Mais peut ai-je ratté l'occasion de me taire ?
Bonjour,
"Zoury" <yanick_lefebvre@hotmail.com> wrote in message
news:%23uu3oN9RDHA.2148@TK2MSFTNGP10.phx.gbl...
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton
traitement...
:O/
Voici ma version de la même fonction si tu veux comparer..
'***
Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As
String
Dim l As Long
l = DateDiff("s", dt1, dt2)
DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _
Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _
Right$("00" & CStr(l Mod 60), 2)
End Function
'***
Cela me parait bien complique !!!
Et Pourquoi pas directement...?
Pourquoi utiliser du Variant pour les paramètres? tu ralentis ton
traitement...
:O/
Voici ma version de la même fonction si tu veux comparer.. '*** Private Function DateTimeDiff(ByRef dt1 As Date, ByRef dt2 As Date) As
String
Dim l As Long l = DateDiff("s", dt1, dt2) DateTimeDiff = Right$("00" & CStr(l 3600), 2) & ":" & _ Right$("00" & CStr((l Mod 3600) 60), 2) & ":" & _ Right$("00" & CStr(l Mod 60), 2) End Function '***
Cela me parait bien complique !!! Et Pourquoi pas directement...?
DateTimeDiff = dt1 - dt2 ?
avec un type date en retour evidemment..
Best Regards
Mais peut ai-je ratté l'occasion de me taire ?
Zoury
: DateTimeDiff = dt1 - dt2 ? : : avec un type date en retour evidemment..
Ah ben ça alors!!!! LOL!! je me botte le postérieur à deux pieds! ;O)
Yves wrote: > Bonjour à tous > > Je voudrais Calculer la différence entre 2 heures > > ex: > MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type > date/heure > > > > --
"François Picalausa" <fpicalausa@chez.com> a écrit dans le message de news:
eS8pmx8RDHA.2144@TK2MSFTNGP11.phx.gbl...
Yves wrote:
> Bonjour à tous
>
> Je voudrais Calculer la différence entre 2 heures
>
> ex:
> MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type
> date/heure
>
>
>
> --
Yves wrote: > Bonjour à tous > > Je voudrais Calculer la différence entre 2 heures > > ex: > MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type > date/heure > > > > --
joseph4
Le vendredi 11 Juillet 2003 à 18:40 par Yves :
Bonjour à tous
Je voudrais Calculer la différence entre 2 heures
ex: MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type date/heure
-- -- Cordialement Yves
Programmeur/Analyste _________________________________________ Merci de répondre dans le newsgroup ,`:O)
La FAQ VB http://faq.vb.free.fr
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = Format(TimeOfDay) If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim hd As Integer Dim md As Integer Dim ha As Integer Dim ma As Integer Dim sa As Integer Dim sd As Integer Dim prestation As Integer Dim h As Integer Dim total As Integer Dim h1 As Integer Dim total1 As Integer md = Minute(Label1.Text) sd = Second(Label1.Text) hd = Hour(Label1.Text) ma = Minute(programme.Text) sa = Second(programme.Text) ha = Hour(programme.Text) h = ((hd * 60) + md) * 60 total = h + sd h1 = ((ha * 60) + ma) * 60 total1 = h1 + sa prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click End End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer2.Enabled = False programme.Enabled = False MsgBox("La notification est désactivée.") End Sub End Class
Le vendredi 11 Juillet 2003 à 18:40 par Yves :
Bonjour à tous
Je voudrais Calculer la différence entre 2 heures
ex:
MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut")
'Champ de type
date/heure
--
--
Cordialement
Yves
Programmeur/Analyste
_________________________________________
Merci de répondre dans le newsgroup ,`:O)
La FAQ VB
http://faq.vb.free.fr
API-Guide, indispensable pour les APIs
http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB
http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires
Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Format(TimeOfDay)
If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim hd As Integer
Dim md As Integer
Dim ha As Integer
Dim ma As Integer
Dim sa As Integer
Dim sd As Integer
Dim prestation As Integer
Dim h As Integer
Dim total As Integer
Dim h1 As Integer
Dim total1 As Integer
md = Minute(Label1.Text)
sd = Second(Label1.Text)
hd = Hour(Label1.Text)
ma = Minute(programme.Text)
sa = Second(programme.Text)
ha = Hour(programme.Text)
h = ((hd * 60) + md) * 60
total = h + sd
h1 = ((ha * 60) + ma) * 60
total1 = h1 + sa
prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click
End
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer2.Enabled = False
programme.Enabled = False
MsgBox("La notification est désactivée.")
End Sub
End Class
ex: MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type date/heure
-- -- Cordialement Yves
Programmeur/Analyste _________________________________________ Merci de répondre dans le newsgroup ,`:O)
La FAQ VB http://faq.vb.free.fr
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = Format(TimeOfDay) If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim hd As Integer Dim md As Integer Dim ha As Integer Dim ma As Integer Dim sa As Integer Dim sd As Integer Dim prestation As Integer Dim h As Integer Dim total As Integer Dim h1 As Integer Dim total1 As Integer md = Minute(Label1.Text) sd = Second(Label1.Text) hd = Hour(Label1.Text) ma = Minute(programme.Text) sa = Second(programme.Text) ha = Hour(programme.Text) h = ((hd * 60) + md) * 60 total = h + sd h1 = ((ha * 60) + ma) * 60 total1 = h1 + sa prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click End End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer2.Enabled = False programme.Enabled = False MsgBox("La notification est désactivée.") End Sub End Class
joseph4
Le vendredi 11 Juillet 2003 à 18:40 par Yves :
Bonjour à tous
Je voudrais Calculer la différence entre 2 heures
ex: MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type date/heure
-- -- Cordialement Yves
Programmeur/Analyste _________________________________________ Merci de répondre dans le newsgroup ,`:O)
La FAQ VB http://faq.vb.free.fr
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = Format(TimeOfDay) If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim hd As Integer Dim md As Integer Dim ha As Integer Dim ma As Integer Dim sa As Integer Dim sd As Integer Dim prestation As Integer Dim h As Integer Dim total As Integer Dim h1 As Integer Dim total1 As Integer md = Minute(Label1.Text) sd = Second(Label1.Text) hd = Hour(Label1.Text) ma = Minute(programme.Text) sa = Second(programme.Text) ha = Hour(programme.Text) h = ((hd * 60) + md) * 60 total = h + sd h1 = ((ha * 60) + ma) * 60 total1 = h1 + sa prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click End End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer2.Enabled = False programme.Enabled = False MsgBox("La notification est désactivée.") End Sub End Class
Le vendredi 11 Juillet 2003 à 18:40 par Yves :
Bonjour à tous
Je voudrais Calculer la différence entre 2 heures
ex:
MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut")
'Champ de type
date/heure
--
--
Cordialement
Yves
Programmeur/Analyste
_________________________________________
Merci de répondre dans le newsgroup ,`:O)
La FAQ VB
http://faq.vb.free.fr
API-Guide, indispensable pour les APIs
http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB
http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires
Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Format(TimeOfDay)
If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim hd As Integer
Dim md As Integer
Dim ha As Integer
Dim ma As Integer
Dim sa As Integer
Dim sd As Integer
Dim prestation As Integer
Dim h As Integer
Dim total As Integer
Dim h1 As Integer
Dim total1 As Integer
md = Minute(Label1.Text)
sd = Second(Label1.Text)
hd = Hour(Label1.Text)
ma = Minute(programme.Text)
sa = Second(programme.Text)
ha = Hour(programme.Text)
h = ((hd * 60) + md) * 60
total = h + sd
h1 = ((ha * 60) + ma) * 60
total1 = h1 + sa
prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click
End
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer2.Enabled = False
programme.Enabled = False
MsgBox("La notification est désactivée.")
End Sub
End Class
ex: MsgBox R.Fields("Heurefin")- R.Fields("HeureDébut") 'Champ de type date/heure
-- -- Cordialement Yves
Programmeur/Analyste _________________________________________ Merci de répondre dans le newsgroup ,`:O)
La FAQ VB http://faq.vb.free.fr
API-Guide, indispensable pour les APIs http://www.allapi.net/agnet/apiguide.shtml
Mz-Tools, add-in pour VB http://www.mztools.com/
bonjour tout le monde
J'ai trouvé une solution efficace à ce problème, mais j'ai rencontré un problème. Le programme affiche 9 fois le message que je veux qu'il affiche quand la condition est vraie.
Je ne sais pas si quelqu'un peut m'aider pour corriger cette erreur. Je veux qu''il affiche seulement une seule fenêtre au lieu de 9 fenêtres quand il trouve que la différence entre les deux heures correspond bien à ce qui est décrit dans la condition.
voici mon code. Je l'ai fait avec VB 2010
Public Class Foires Private Sub foires_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Timer1.Start() programme.Text = (TimeOfDay)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Label1.Text = Format(TimeOfDay) If Label1.Text = "12:00:00" Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim hd As Integer Dim md As Integer Dim ha As Integer Dim ma As Integer Dim sa As Integer Dim sd As Integer Dim prestation As Integer Dim h As Integer Dim total As Integer Dim h1 As Integer Dim total1 As Integer md = Minute(Label1.Text) sd = Second(Label1.Text) hd = Hour(Label1.Text) ma = Minute(programme.Text) sa = Second(programme.Text) ha = Hour(programme.Text) h = ((hd * 60) + md) * 60 total = h + sd h1 = ((ha * 60) + ma) * 60 total1 = h1 + sa prestation = (total - total1)
If (prestation = 28800) Then My.Computer.Audio.Play(My.Resources.note, AudioPlayMode.Background)
End Sub
Private Sub QuitterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitterToolStripMenuItem.Click End End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer2.Enabled = False programme.Enabled = False MsgBox("La notification est désactivée.") End Sub End Class