como criar um tempo de espera entre os comandos?
Quero alterar um label para informar qual ação estará sendo executada. já tentei com sleep e não estou acertando.
seria assim
Label1.Text = "texto1" System.Threading.Thread.Sleep(3000) (executa os comandos 1) Label1.Text = "texto2" System.Threading.Thread.Sleep(3000) (executa os comandos 2) Label1.Text = "texto3" (executa os comandos 3)
o que está acontecendo é esperar 6 segundos e ir direto para o "texto3" (acredito que execute tão rápido os 3 que só vejo o ultimo)
também já tentei assim e não consegui:
Public Class Form1 Public Sub Esperar(ByVal QuantosSegundos As UInt16) Dim Final As Date = TimeOfDay.AddSeconds(QuantosSegundos) While Not TimeOfDay.Second >= Final.Second Application.DoEvents() End While End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Label1.Text = "texto1" Esperar(3) Label1.Text = "texto2" Esperar(3) Label1.Text = "texto3" Esperar(3) End SubEnd Class
Tem como fazer isso ?
Obrigado
criei 3 timers. não sei se é o certo ou se é SeuManuel Developer
Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Timer1.Enabled = True End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick Label1.Text = "texto1" Timer1.Enabled = False Timer2.Enabled = True End Sub Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick Label1.Text = "texto2" Timer2.Enabled = False Timer3.Enabled = True End Sub Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick Label1.Text = "texto3" Timer3.Enabled = False End SubEnd Class
Discussão (1)
Carregando comentários...