Anzitutto grazie a tutti anticipatamente.
Mi spiego meglio vorrei realizzare un programma che effettua un determinato numero di conti alla rovescia esempio che fa il conto alla rovescia da 20 a 0 per n volte, e che allo scadere di ogni conto alla rovescia(in questo caso da 20 secondi) ci sia successivamente una pausa sempre scelta dall'utente di ad esempio 10 secondi che di conseguenza si ripete n volte.
Sto provando in Visual Basic 2008, ma anticipo che conosco solo un po’ di visual basic 6, ma ho usato vb 2008 poichè ho trovato facile lo strumento timer, con questi sono riuscito a fare un semplice conto alla rovescia ma per il problema posto sopra ho fatto delle prove fallimentari, una è la seguente ma resta fermo sulla cifra che inserisco.
Ho allegato un immagine per far vedere come dovrebbe essere l'ide del programma
Questo è il codice del programma
codice:Public Class Form1 'Pulsante Start Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() lblcountdown.Text = Val(NumericUpDown2.Value) NumericUpDown1.Enabled = False NumericUpDown2.Enabled = False NumericUpDown3.Enabled = False End Sub 'Pulsante pausa Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub 'pulsante riprendi Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Timer1.Start() End Sub 'pulsante stop Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Timer1.Stop() lblcountdown.Text = "" NumericUpDown1.Value = 0 NumericUpDown2.Value = 0 NumericUpDown3.Value = 0 NumericUpDown1.Enabled = True NumericUpDown2.Enabled = True NumericUpDown3.Enabled = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Interval = 1000 lblcountdown.Text = lblcountdown.Text - 1 Dim round As Integer Dim active As Integer Dim pause As Integer Dim tot As Integer round = NumericUpDown1.Value active = NumericUpDown2.Value pause = NumericUpDown3.Value tot = (active + pause) * round lbltotal.Text = tot For i As Integer = 1 To round Step 1 lblcountdown.Text = active Timer1.Start() If lblcountdown.Text = 0 Then tot = tot - active Timer1.Stop() End If lblcountdown.Text = pause Timer1.Start() If lblcountdown.Text = 0 Then tot = tot - pause Timer1.Stop() End If If tot = 0 Then Timer1.Stop() NumericUpDown1.Enabled = True NumericUpDown2.Enabled = True NumericUpDown3.Enabled = True lblcountdown.Text = 0 End If Next End Sub End Class

Rispondi quotando