By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,529 Members | 864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,529 IT Pros & Developers. It's quick & easy.

Timer does not count when in a IF statement

P: 1
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.

Share this Question
Share on Google+
3 Replies


Expert 100+
P: 1,035
It looks like you need DoEvents
Jan 3 '15 #2

Expert 100+
P: 1,035
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
Expert Mod 10K+
P: 12,359
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.