Public Class clsTimerSW
Private m_timer As Timer
Private m_sw As Stopwatch
Private m_lbl As Label = Nothing
Sub New(ByVal msInterval As Integer, Optional ByRef lbl As Label = Nothing)
m_lbl = lbl
m_timer = New Timer()
m_timer.Interval = msInterval
AddHandler m_timer.Tick, AddressOf m_timer_Tick
m_sw = New Stopwatch()
End Sub
Public Sub StartTimerSW()
If Not m_lbl Is Nothing Then m_lbl.Text = ""
m_sw.Start()
m_timer.Enabled = True
End Sub
Public Sub StopTimerSW()
m_sw.Stop()
m_timer.Enabled = False
End Sub
Public Sub ResetTimerSW()
m_sw.Restart()
If Not m_lbl Is Nothing Then
m_lbl.Text = GetElapsedTime()
End If
End Sub
Public Sub SetInterval(ByVal ms As Integer)
m_timer.Interval = ms
End Sub
Public Function IsEnabled() As Boolean
Return m_timer.Enabled
End Function
Public Function GetElapsedTime() As String
Return String.Format("{0}:{1}:{2}", _
m_sw.Elapsed.Hours.ToString("00"), _
m_sw.Elapsed.Minutes.ToString("00"), _
m_sw.Elapsed.Seconds.ToString("00"))
End Function
Private Sub m_timer_Tick(sender As Object, e As EventArgs)
If Not m_lbl Is Nothing Then
m_lbl.Text = GetElapsedTime()
m_lbl.Refresh()
End If
End Sub
End Class
Suscribirse a:
Enviar comentarios (Atom)
VBA Access. Redondeo de números decimales con el método medio redondeo. Alternativa a la función Round (bankers round)
Private Function Redondeo(ByVal Numero As Variant, ByVal Decimales As Integer) As Double 'Aplica método medio redondeo (half round ...
-
Option Compare Database Option Explicit '***************************** ' 'Ejemplo de uso ' 'selecciona 1 ficher...
-
Option Compare Database Option Explicit 'Zip / UnZip file or folder 'http://www.codekabinett.com/rdumps.php?Lang=2&targetDoc...
No hay comentarios:
Publicar un comentario