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
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
usa l'oggetto timer..lo imposti come 1000 ms e nel suo evento fai scirvere il tempo trascorso...
mhh...nn sn tanto pratico... come debbo fare?
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!!! ***
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
quando poi faccio reset... se sono le 17.53
comincia a contare da 17.53.01 è normale?
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
?
Puoi fare in 2 modi:
o sfrutti la variabile MyStrTmp e quindi avrai:
oppure se vuoi usare il textbox:codice:tmptrascorso = Time - MyStrTmp MyOre= Format(tmptrascorso, "hh") MyMin= Format(tmptrascorso, "nn") MySec= Format(tmptrascorso, "ss")
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!!! ***
Perchè ho sbagliato il codice del command4 che giusto è:Originariamente inviato da giofast
quando poi faccio reset... se sono le 17.53
comincia a contare da 17.53.01 è normale?
codice:Private Sub Command4_Click() Timer1.Enabled = False Text1.Text = "" MyStrTmp = Time End Sub
*** Rachele TI AMO DA MORIRE!!! ***
grazie mille)