Creando Cronómetro en Visual Basic 6

Para crear este cronómetro(Img 1.1) de forma facil, utilizaremos dos CommandButton, un Timer y un label:
Timer1:
intervalo = 1000

Img 1.1


Option Explicit


Dim Horas As Integer, Minutos As Integer, Segundos As Integer   'Crearmos la variable para el tiempo

' Boton Iniciar y Detener
Private Sub Command1_Click()
    If Command1.Caption = "Iniciar" Then
        Timer1.Enabled = True
        Command1.Caption = "Pausar"
        Command2.Enabled = False
    Else
        Timer1.Enabled = False
        Command1.Caption = "Iniciar"
        Command2.Enabled = True
    End If
End Sub

' Boton reiniciar
Private Sub Command2_Click()
    Horas = 0
    Minutos = 0
    Segundos = 0
    Label1.Caption = "00:00:00"
    Command1.Caption = "Iniciar"
End Sub

Private Sub Form_Load()
    Timer1.Interval = 1000
    Command1.Caption = "Iniciar"
    Command2.Caption = "Detener"
    Timer1.Enabled = False
End Sub

Private Sub Timer1_Timer()
    Segundos = Segundos + 1
 
    If Segundos > 59 Then
        Minutos = Minutos + 1
        Segundos = 0
    End If
 
    If Minutos > 59 Then
        Horas = Horas + 1
        Minutos = 0
    End If
 
    Label1.Caption = Format(Horas, "00") & ":" & Format(Minutos, "00") & ":" & Format(Segundos, "00")
End Sub


Crear Cronómetro en Visual Basic 2008
https://www.yalpublicidad.com/blog/crear-cronometro-en-visual-basic-2008

Yuri Lizama A.
website:
http://www.yalpublicidad.com/




ENLACES RELACIONADOS

Ingresar array en ListBox de Visual Basic 6

Creando Cronómetro en Visual Basic 6





Comentarios

Publicar un comentario