electric Posted November 28, 2006 at 04:22 PM Report #67314 Posted November 28, 2006 at 04:22 PM Boas, eu ja trabalhei em vb2003 e aprendi umas coisinhas mas agora keria desenvolver 1 programazinho, so k o meu problema apesar dele ja funcionar é conseguir por o tempo colocado no timer a ser mostrado numa lbl mas a descontar. o meu programa bazeia-se em : escolher 1 ficheiro colocar o tempo numa tbx k ira ser o tempo do timer ao carregar no btn iniciar o timer passa a true e o tempo começa a contar quando chegar ao fim desse mxm tempo o programa k escolhi anteriormente arranca o problema é colocar o tempo a ser mostrado numa lbl mas ao contrrio e polo a cuncionar :\ se me poderem ajudar agradeço, se esta confuso peço desculpa lol eu tento reesplicar melhor ... []'s
AriOps Posted November 28, 2006 at 04:32 PM Report #67316 Posted November 28, 2006 at 04:32 PM então fazes assim, no timer_tick pões lblTal.Text = Val(lblTal.Text) - 1 , tens é de ter previamente o número na label quando o contador fica enabled. Acho que é isto que queres 😄 Daniel Correia
Icaro Posted November 28, 2006 at 05:26 PM Report #67324 Posted November 28, 2006 at 05:26 PM então fazes assim, no timer_tick pões lblTal.Text = Val(lblTal.Text) - 1 , tens é de ter previamente o número na label quando o contador fica enabled. Acho que é isto que queres 😄 Está bem visto sim senhor Public Class Form1 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Me.Label1.Text = Val(Label1.Text) - 1 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Timer1.Start() End Sub Private Sub Label1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.TextChanged If Me.Label1.Text = "0" Then Me.Timer1.Stop() Me.Label1.Text = "10" Form2.Show() End If End Sub End Class
electric Posted November 28, 2006 at 06:00 PM Author Report #67329 Posted November 28, 2006 at 06:00 PM nepia n ta a resultar :\ eu tentei tb por como text o nº 25 visto serem 25 segundos mas tb n descontou... eu deixo aki a baixo o meu codigo pode ser k seja + facil :\ Private Sub BtnEscolher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEscolher.Click Dim Resultado As DialogResult Resultado = DlgoFicheiro.ShowDialog If (Resultado = Windows.Forms.DialogResult.OK) Then TbxFicheiro.Text = DlgoFicheiro.FileName End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick Dim P As New Process Try If (TbxFicheiro.Text <> "") Then P.StartInfo.FileName = TbxFicheiro.Text 'P.StartInfo.Arguments = TbxTempo.Text P.Start() P.WaitForInputIdle() 'Thread.Sleep(2000) 'P.Kill() End If Catch ex As Exception MessageBox.Show("Ficheiro não encontrado") End Try LblDescontar.Text = Val(LblDescontar.Text) - 1 End Sub Private Sub BtnIniciar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIniciar.Click tmr.Enabled = True tmr.Interval = CbxTempos.Text * 1000 ' TbxDescontar.Text = CbxTempos.Text End Sub Private Sub BtnParar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnParar.Click tmr.Enabled = False End Sub End Class
AriOps Posted November 28, 2006 at 06:04 PM Report #67330 Posted November 28, 2006 at 06:04 PM esse tmr é o timer? se sim esqueceste-te de substituir na linha do Timer1.Tick o Timer1 pelo tmr 😄 Daniel Correia
electric Posted November 28, 2006 at 06:09 PM Author Report #67332 Posted November 28, 2006 at 06:09 PM ya é mas mxm assim o problema n é dai ... o k notei é k meto algo a abrir de 15 em 15 segundos e começa a contar kando abre como n para ta sempre a reabrir aos 15 segundos, logo vai contado -1 -2 e por ai ...
AriOps Posted November 28, 2006 at 06:19 PM Report #67335 Posted November 28, 2006 at 06:19 PM então tens de meter um if lblTal.Text = 0 Then tmr.Enabled = False 😄 Daniel Correia
electric Posted November 28, 2006 at 06:23 PM Author Report #67337 Posted November 28, 2006 at 06:23 PM sim isso eu sei mas por agora n me serve de nd visto não fazer a contagem :\ eu tenho la 15 segundos tenho o codigo como diseste LblDescontar.Text = Val(LblDescontar.Text) - 1 mas a lbl permanece limpa so kando da a volta aos 15 segundos é k conta -1 passado + 15 segundos -2 e por ai :\
Icaro Posted November 28, 2006 at 06:25 PM Report #67338 Posted November 28, 2006 at 06:25 PM então tens de meter um if lblTal.Text = 0 Then tmr.Enabled = False 😄 e já agora nesse if lbl.text = valor inicial senão fica no 0
AriOps Posted November 28, 2006 at 06:26 PM Report #67340 Posted November 28, 2006 at 06:26 PM já tens o label com um valor logo de inicio? Ou seja, se já tem o valor 15 no seu texto... Se não adiciona lblTal.Text = 15 no evento load da form:) Daniel Correia
electric Posted November 28, 2006 at 06:29 PM Author Report #67342 Posted November 28, 2006 at 06:29 PM ya mas o k ele me ta a fazer ai é dizer k vai mostrar akela img ou la o k é 15 X eu keria k esses 15 fossem em tempo real mas em segundos nestes caso 15,14,13.... k é pro ppl ter a noção de kanto tempo falta pra aparecer o k mandei abrir tas a perceber :\
Icaro Posted November 28, 2006 at 06:30 PM Report #67343 Posted November 28, 2006 at 06:30 PM sim isso eu sei mas por agora n me serve de nd visto não fazer a contagem :\ eu tenho la 15 segundos tenho o codigo como diseste LblDescontar.Text = Val(LblDescontar.Text) - 1 mas a lbl permanece limpa so kando da a volta aos 15 segundos é k conta -1 passado + 15 segundos -2 e por ai :\ Defeniste o valor inicial do lbl? porque senão ele só começa a aparecer do -1 para a frente
electric Posted November 28, 2006 at 06:32 PM Author Report #67344 Posted November 28, 2006 at 06:32 PM sim ja fiz isso
AriOps Posted November 28, 2006 at 06:36 PM Report #67345 Posted November 28, 2006 at 06:36 PM posta aí o teu código actual, para eu ver qual é o problema ali no visual studio 😄 Daniel Correia
Icaro Posted November 28, 2006 at 06:45 PM Report #67346 Posted November 28, 2006 at 06:45 PM bom não sei se é disso porque não testei o código mas não necessitas de estabelecer o intrevalo com código basta pores nas propriedades do timer 1000 que te faz a contagem em segundos
electric Posted November 28, 2006 at 06:47 PM Author Report #67348 Posted November 28, 2006 at 06:47 PM Private Sub BtnEscolher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnEscolher.Click Dim Resultado As DialogResult Resultado = DlgoFicheiro.ShowDialog If (Resultado = Windows.Forms.DialogResult.OK) Then TbxFicheiro.Text = DlgoFicheiro.FileName End If End Sub Private Sub Tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick Dim P As New Process Try If (TbxFicheiro.Text <> "") Then P.StartInfo.FileName = TbxFicheiro.Text P.Start() P.WaitForInputIdle() End If Catch ex As Exception MessageBox.Show("Ficheiro não encontrado") End Try LblDescontar.Text = Val(LblDescontar.Text) - 1 If LblDescontar.Text = 0 Then tmr.Enabled = False End If End Sub Private Sub BtnIniciar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIniciar.Click tmr.Enabled = True tmr.Interval = CbxTempos.Text * 1000 End Sub Private Sub BtnParar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnParar.Click tmr.Enabled = False End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load LblDescontar.Text = 15 End Sub End Class
electric Posted November 28, 2006 at 06:48 PM Author Report #67349 Posted November 28, 2006 at 06:48 PM bom não sei se é disso porque não testei o código mas não necessitas de estabelecer o intrevalo com código basta pores nas propriedades do timer 1000 que te faz a contagem em segundos sim faz a contagem em segundos so k o meu timer é efenido pelo user ou tas a falar de meter outro timer so pra ontar akilo ?
AriOps Posted November 28, 2006 at 06:48 PM Report #67350 Posted November 28, 2006 at 06:48 PM bom não sei se é disso porque não testei o código mas não necessitas de estabelecer o intrevalo com código basta pores nas propriedades do timer 1000 que te faz a contagem em segundos ele já tem isso nesta linha: tmr.Interval = CbxTempos.Text * 1000 eu não sei é se ele já tem um valor default no campo CbxTempos Daniel Correia
Icaro Posted November 28, 2006 at 06:49 PM Report #67351 Posted November 28, 2006 at 06:49 PM tmr.Interval = CbxTempos.Text * 1000 ' TbxDescontar.Text = CbxTempos.Text End Sub não entendo esta linha, o utilizador escolhe a velocidade do timer?
Icaro Posted November 28, 2006 at 06:52 PM Report #67352 Posted November 28, 2006 at 06:52 PM sim faz a contagem em segundos so k o meu timer é efenido pelo user ou tas a falar de meter outro timer so pra ontar akilo ? então se o user escolher diferente deo valor 1 já nãoo vai descontar em segundos
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now