index.php?id=9

Creando Cronómetro en Visual Basic 6

Por Yal Publicidad


Publicado el Jue 27 de Settember del 2018 a las 21:45



Para crear este cronómetro(Img 1.1) de forma facil, utilizaremos dos CommandButton, un Timer y un label.

En este ejemplo crearemos un cronómetro simple 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

 

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


Deja un comentario:
Buscar
Acerca de Nosotros
@yalpublicidad Agencia de publicidad online. 21 años de experiencia en el diseño y desarrollo de imagen e identidad corporativa de tu empresa...