Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Loop Until Minute = Value

Status
Not open for further replies.

dcrpepper

IS-IT--Management
Jan 14, 2004
8
GB
i am trying to write a mini backup application that backs up a file every minute or so to a folder.

i have got the minute part of date in a variable eg 05 and have a do loop until minute = the selected value.

everything works except it really slows down and almost crashes the computer. Any suggestions much appreciated i am new to visual basic so i might be going about this the complete wrong way.

Cheers.
 
Think about using a timer control with an interval of 60 seconds. (60000)
 
If you still have issues after trying the timer solution you could post part of the code in question so we could see how your doing this. Also, does the code do anything else besides the copy (backup)? Depending on what and when, this could be causing some problems too. I suspect adding the timer will correct the problem though.
 
If opt1min = True Then
Do
varDateTime = Now()
varTimeVal = Mid$(varDateTime, 15, 2)
Loop Until (varTimeVal = 30)
FileCopy txtBackupFile, Dir1 & "\" & txtTest3
End If

this is the code i am using the time value is tempory and will change depending on the value the user selects.

how would i use the timer object instead.

thanks
 
Put a timer control on a form, and set it's interval property to 60000, and it's enabled to true.

Every minute it's Timer event will fire, so you can put whatever code you like in there to do whatever you want.

mmilan
 
thanks ill try that. how do i make the interval selectable
by the user
 
Provide a combo box with a number of seconds on it, and in the click event set the timer's interval to this value multiplied by 1000.

You should also be aware that the timer control has an upper limit of ((2^16)-1)/1000 seconds - around 65.

mmilan
 
sorry, whats the limit in seconds i didn't understand that
cheers,
 
He's trying to say that the Interval property of the VB Timer can hold a maximum value of 65535. Since the Interval value is milliseconds, this makes the maximum interval for the Timer 65.535 seconds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top