OVH Cloud OVH Cloud

Heure dans la barre de titre d'un userform

4 réponses
Avatar
Michel.Girard
Bonjour
Je désire avoir dans ma barre de titre d'un userform l'heure qui défile.
Est-ce possible ?
Merci beaucoup
Michel

4 réponses

Avatar
Michel Pierron
Bonjour Michel;
Dans ton module UserForm:
Option Explicit
Private oTimer As Boolean, Title As String

Private Sub WithTimer()
On Error GoTo Fin
Dim Start As Single
1: Start = Timer
While Timer < Start + 0.1: DoEvents: Wend
Me.Caption = Title & Time
If oTimer Then GoTo 1
Fin:
End Sub

Private Sub UserForm_Activate()
oTimer = True: WithTimer
End Sub

Private Sub UserForm_Initialize()
Title = Me.Caption & " - "
Me.Caption = Title & Time
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
oTimer = False
End Sub

MP

"Michel.Girard" a écrit dans le message de
news:
Bonjour
Je désire avoir dans ma barre de titre d'un userform l'heure qui défile.
Est-ce possible ?
Merci beaucoup
Michel







Avatar
Michel.Girard
Bonjour Michel
C'est vraiment remarquable !!!
Un très grand merci
Bravo!!!
Michel

"Michel Pierron" a écrit dans le message de news:
OsM%
Bonjour Michel;
Dans ton module UserForm:
Option Explicit
Private oTimer As Boolean, Title As String

Private Sub WithTimer()
On Error GoTo Fin
Dim Start As Single
1: Start = Timer
While Timer < Start + 0.1: DoEvents: Wend
Me.Caption = Title & Time
If oTimer Then GoTo 1
Fin:
End Sub

Private Sub UserForm_Activate()
oTimer = True: WithTimer
End Sub

Private Sub UserForm_Initialize()
Title = Me.Caption & " - "
Me.Caption = Title & Time
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
oTimer = False
End Sub

MP

"Michel.Girard" a écrit dans le message
de
news:
Bonjour
Je désire avoir dans ma barre de titre d'un userform l'heure qui défile.
Est-ce possible ?
Merci beaucoup
Michel










Avatar
Jean-François Aubert
Salut Michel,

Une autre (moins bien que celle de Michel Pierron)


dans un module standart
'***************************
Option Explicit
Public I As Integer
Public fIni As Boolean
Public fin24h As Boolean
Declare Function GetTickCount Lib "Kernel32" () As Long

Sub Minuterie(Milliseconde As Long)
Dim Arret As Long
Arret = GetTickCount() + Milliseconde
Do While GetTickCount() < Arret
UserForm1.Caption = Now
DoEvents
Loop
End Sub

Sub affiche_heure()
UserForm1.Show
' si pas de fermeture de l'userform,
' tourne pendant 24 heures !
Do While I < 86400
UserForm1.Repaint
Minuterie 1000
If fIni = True Then
fIni = False
Unload UserForm1
I = 0
Exit Sub
End If
I = I + 1
Loop
fin24h = True
Unload UserForm1
End Sub


'**************************
dans le module de l'userform
'***************************
Option Explicit

Private Sub UserForm_Initialize()
fIni = False
fin24h = False
I = 0
End Sub

Private Sub UserForm_Terminate()
If fin24h = False Then
fIni = True
End If
End Sub

'***************************
--
Amicalement

Jean-François Aubert
{Vaudois de la Côte Lémanique}


"Michel.Girard" a écrit dans le message de
news:
Bonjour
Je désire avoir dans ma barre de titre d'un userform l'heure qui défile.
Est-ce possible ?
Merci beaucoup
Michel







Avatar
Michel.Girard
Merci beaucoup JF c'est très sympa de ta part.
Michel

"Jean-François Aubert" <à a écrit dans le message de
news: %
Salut Michel,

Une autre (moins bien que celle de Michel Pierron)


dans un module standart
'***************************
Option Explicit
Public I As Integer
Public fIni As Boolean
Public fin24h As Boolean
Declare Function GetTickCount Lib "Kernel32" () As Long

Sub Minuterie(Milliseconde As Long)
Dim Arret As Long
Arret = GetTickCount() + Milliseconde
Do While GetTickCount() < Arret
UserForm1.Caption = Now
DoEvents
Loop
End Sub

Sub affiche_heure()
UserForm1.Show
' si pas de fermeture de l'userform,
' tourne pendant 24 heures !
Do While I < 86400
UserForm1.Repaint
Minuterie 1000
If fIni = True Then
fIni = False
Unload UserForm1
I = 0
Exit Sub
End If
I = I + 1
Loop
fin24h = True
Unload UserForm1
End Sub


'**************************
dans le module de l'userform
'***************************
Option Explicit

Private Sub UserForm_Initialize()
fIni = False
fin24h = False
I = 0
End Sub

Private Sub UserForm_Terminate()
If fin24h = False Then
fIni = True
End If
End Sub

'***************************
--
Amicalement

Jean-François Aubert
{Vaudois de la Côte Lémanique}


"Michel.Girard" a écrit dans le message
de news:
Bonjour
Je désire avoir dans ma barre de titre d'un userform l'heure qui défile.
Est-ce possible ?
Merci beaucoup
Michel