Visualizzazione dei risultati da 1 a 10 su 10

Discussione: [vb6] Cronometro

  1. #1

    [vb6] Cronometro

    ragazzi...come posso creare un cronometro che segna in un text box il tempo trascorso? e magari tramite dei command box dare il comando azzera, continua e stop?..
    grazie mille

  2. #2
    Utente bannato
    Registrato dal
    Sep 2001
    Messaggi
    534
    usa l'oggetto timer..lo imposti come 1000 ms e nel suo evento fai scirvere il tempo trascorso...

  3. #3
    mhh...nn sn tanto pratico... come debbo fare?

  4. #4
    codice:
    'Sono necessari:
    'Un controllo Timer
    '4 Pulsanti
    'Una textbox
    
    Dim MyStrTmp
    Dim Pausa As Boolean
    
    Private Sub Command1_Click()
        Timer1.Enabled = True
    End Sub
    
    Private Sub Command2_Click()
        Timer1.Enabled = False
    End Sub
    
    Private Sub Command3_Click()
        Pausa = Not Pausa
    End Sub
    
    Private Sub Command4_Click()
        Timer1.Enabled = False
        Text1.Text = ""
        MyStrTmp = 0
    End Sub
    
    Private Sub Form_Load()
        Command1.Caption = "Start"
        Command2.Caption = "Stop"
        Command3.Caption = "Pause"
        Command4.Caption = "Reset"
        Text1.Text = ""
        Timer1.Interval = 1000
        Timer1.Enabled = False
        Text1.Text = ""
        MyStrTmp = Time
    End Sub
    
    Private Sub Timer1_Timer()
        If Not Pausa Then
            tmptrascorso = Time - MyStrTmp
            Text1.Text = Format(tmptrascorso, "hh:nn:ss")
        End If
    End Sub
    *** Rachele TI AMO DA MORIRE!!! ***

  5. #5
    ho notato ke quando faccio pause e poi lo ripremo ... se lascio a 40 e passano 10 secondi... ricomincia da 50... invece di ricominciare da 40

  6. #6
    quando poi faccio reset... se sono le 17.53

    comincia a contare da 17.53.01 è normale?

  7. #7
    ho risolto..
    se per esempio, salvo il contenuto della text box in una variabile TEMPO

    come faccio a sapere quanti secondi minuti e ore sono contenute nel cronometraggio
    se è scritto: 01.15.15 magari è possibile ottenere i tre valori in tre variabili differenti?
    tipo
    h = 1
    m = 15
    s = 15
    ?

  8. #8
    Puoi fare in 2 modi:

    o sfrutti la variabile MyStrTmp e quindi avrai:
    codice:
    tmptrascorso = Time - MyStrTmp
    MyOre= Format(tmptrascorso, "hh")
    MyMin= Format(tmptrascorso, "nn")
    MySec= Format(tmptrascorso, "ss")
    oppure se vuoi usare il textbox:
    codice:
    tmpinTextBox = Text1.Text
    MyOre = Left(Text1.Text,2)
    MyMin = Mid(Text1.Text,4,2)
    MySec = Right(Text1.Text,2)
    *** Rachele TI AMO DA MORIRE!!! ***

  9. #9
    Originariamente inviato da giofast
    quando poi faccio reset... se sono le 17.53

    comincia a contare da 17.53.01 è normale?
    Perchè ho sbagliato il codice del command4 che giusto è:
    codice:
    Private Sub Command4_Click()
        Timer1.Enabled = False
        Text1.Text = ""
        MyStrTmp = Time
    End Sub
    *** Rachele TI AMO DA MORIRE!!! ***

  10. #10
    grazie mille )

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.