Home > Software engineering >  VB: the TIMER can't normally closed question
VB: the TIMER can't normally closed question

Time:10-05

Each great spirit:
I there is a form of engineering FORM1, when the LOAD, opened the TIMER1, arguably when unload FORM1 TIMER1 should be followed stopped, but when I was in form2 found TIMER1 or running, or every other interval is executed in the timer event, then I amend the program to:
Me. The Timer1. Enable=False
Form2. Show
Unload Me
But even if like this, why form2 timer1 when running in the running events or running? Do not know to have also encountered such a problem, you masters, genuflect is begged help the younger brother to solve this problem, thank you!

CodePudding user response:

The problem in other places, the three lines of code you provide is can't see a problem,

CodePudding user response:

You should be somewhere outside FORM1 cited Timer1?
Otherwise, you will be somewhere cited Form1, Form1 closed but no real release

CodePudding user response:

How do you know the timer1 from1 still running?

CodePudding user response:

I have a pop up a timer of MSGBOX, so I know

CodePudding user response:

I also encountered the same problem:
I wrote the following code in the timer1

If i> 4 then
I=0
Timer1. Enable=false
Msgbox (" completed conversion ")
End the if

Timer1 didn't stop as a result, MSG also plays out,,,
Please help

CodePudding user response:

Normally this kind of problem is caused DoEvents

CodePudding user response:

reference 5 floor u014598683 reply:
I also encountered the same problem:
I wrote the following code in the timer1

If i> 4 then
I=0
Timer1. Enable=false
Msgbox (" completed conversion ")
End the if

Timer1 didn't stop as a result, MSG also plays out,,,
Please help


Well,, you will perform even timer1 closed mag, and must be performed if the statements inside ah, the next is not carried out,

CodePudding user response:

 Timer1 

Regard him as the search criteria, look at your code, if there are other places in the call,

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Timer1, controls the best in the inside of the label attribute set to false, the call is set to true, when call ends, the set to false,

CodePudding user response:

Like this:

Level 1 set a form of variable

Dim blnStop As Boolean

2 in your Timer event code add

If blnStop Then
Timer1. Enabled=False
The Exit Sub
End the If

3 in the event of an Form_Unload added

BlnStop=True

CodePudding user response:

I judge this I not set value (0) so you are not here TIMER1 running, but the statement in judge for themselves... Cause MSGBOX run...

CodePudding user response:

reference 5 floor u014598683 reply:
I also encountered the same problem:
I wrote the following code in the timer1

If i> 4 then
I=0
Timer1. Enable=false
Msgbox (" completed conversion ")
End the if

Timer1 didn't stop as a result, MSG also plays out,,,
Please help


You the timer1. Enable=false is wrong, should be the timer1. Enabled=false (see is Enabled)
You write a few places are wrong, certainly can't stop,

CodePudding user response:

The original poster is the.net version at a later time. The timer control not inherit form1 properties, is a public control, will not stop by your form1 close, if you want to use, should be in the timer attribute set its enable to false, in the form called timer1 place with timer1. Enable=true, at the end of the call to timer1. Enable=false
  • Related