468,133 Members | 1,187 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Timer does not count when in a IF statement

In my program I have an If statement, where I check if a file exist.

check:
Expand|Select|Wrap|Line Numbers
  1.         If FileFolderExists(FGH2) Then
  2.             TextBox6.Text = TextBox3.Text
  3.         Else
  4.             GoTo check
  5.         End If
  6.  
  7.  
  8. I have a timer counting how many seconds it takes before my file is visible (created)
  9.  
  10.  Public Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  11.         TextBox3.Text = TextBox3.Text + 1
  12.     End Sub
But when my prgram is in the If statement it does not count the passed seconds.
Any tips why this happens.
Jan 3 '15 #1

✓ answered by Rabbit

The reason it's not ticking is because code doesn't run while other code is running unless you tell it to.

Also, ticks are not accurate. Instead, store the start time and compare it with the current time.

3 1094
Luuk
1,043 Expert 1GB
It looks like you need DoEvents
Jan 3 '15 #2
Luuk
1,043 Expert 1GB
oops, for the DoEvents, I have the wrong link
I meant this one:
http://msdn.microsoft.com/en-us/libr...vs.110%29.aspx
Jan 3 '15 #3
Rabbit
12,511 Expert Mod 8TB
The reason it's not ticking is because code doesn't run while other code is running unless you tell it to.

Also, ticks are not accurate. Instead, store the start time and compare it with the current time.
Jan 3 '15 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by sincethe2004 | last post: by
2 posts views Thread by =?Utf-8?B?U3VyZXNoIFJlZGR5?= | last post: by
8 posts views Thread by Rainer Queck | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.