aitsu01
asked on
how to extend the funtion Timer?
Hello Experts,
how to extend the Timer function over 60000 milliseconds??
I need to to extend the time of r one of my function
how to extend the Timer function over 60000 milliseconds??
I need to to extend the time of r one of my function
Here is another very similar approach using a Date variable...
Option Explicit
Private minutes As Integer
Private targetTime As Date
Private Sub Form_Load()
Timer1.Enabled = False
minutes = 11
SetNewTargetTime
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub SetNewTargetTime()
targetTime = DateAdd("n", minutes, Now)
End Sub
Private Sub Timer1_Timer()
If Now > targetTime Then
Timer1.Enabled = False
' do something here...
Debug.Print "something"
SetNewTargetTime
Timer1.Enabled = True
End If
End Sub
ASKER
Hello angellll,
the value of the gTimerInterval = 100 ?youe mean 100 seconds or 100 milliseconds?
the value of the gTimerInterval = 100 ?youe mean 100 seconds or 100 milliseconds?
ASKER
Hello idle mind;
refered to targetTime = DateAdd("n", minutes, Now)
what stands the "n" for?
refered to targetTime = DateAdd("n", minutes, Now)
what stands the "n" for?
>the value of the gTimerInterval = 100 ?youe mean 100 seconds or 100 milliseconds?
would mean 100 seconds, as the timer1.interval is set to 1000 (means 1 second).
>refered to targetTime = DateAdd("n", minutes, Now)
> what stands the "n" for?
n stands for minutes, see the reference:
http://msdn2.microsoft.com/en-us/library/cb7z8yf9.aspx
would mean 100 seconds, as the timer1.interval is set to 1000 (means 1 second).
>refered to targetTime = DateAdd("n", minutes, Now)
> what stands the "n" for?
n stands for minutes, see the reference:
http://msdn2.microsoft.com/en-us/library/cb7z8yf9.aspx
ASKER
if i have two timer how can i solve it??
for example with timer1 and timer2
for example with timer1 and timer2
what are the 2 timers doing?
ASKER
timer1 upload my file.txt to my ftp web space
timer2 delete the uploaded text file and load the form1
see below here for the code:
timer2 delete the uploaded text file and load the form1
see below here for the code:
Private Sub Timer1_Timer()
Dim host_name As String
Dim time As String
Dim user As String
Dim directory As String
Unload form1
'On Error Resume Next
Texttime = Now
Enabled = False
MousePointer = vbHourglass
txtResults.Text = "Working"
txtResults.SelStart = Len(txtResults.Text)
DoEvents
host_name = txtHost.Text
If LCase$(Left$(host_name, 6)) <> "ftp://" Then host_name = "ftp://" & host_name
inetFTP.URL = host_name
inetFTP.UserName = txtUserName.Text
inetFTP.Password = txtPassword.Text
time = CStr(Time)
directory = mydirectoryfile
inetFTP.Execute , "mkdir " & directory
Pause 1000 'give time for the process completing operation
inetFTP.Execute , "cd " & directory
Pause 1000
On Error Resume Next
inetFTP.Execute , "Put " & _
"c:\myfile.txt" & " & "_" & time
End Sub
Private Sub Timer2_Timer()
Kill "c:\myfile.txt"
Load form1
End Sub
why don't you kill and load form1 at the end of the timer1 ?
ASKER
an eror will appear
i used the second timer just to get a little more time to complete the operation
anyway let me try again with your suggestion i resumed amny time that code so maybe now it will works
i used the second timer just to get a little more time to complete the operation
anyway let me try again with your suggestion i resumed amny time that code so maybe now it will works
>an eror will appear
would be interesting to learn that error.
anyhow, how much time between that last line and the additional steps?
it would go like this:
would be interesting to learn that error.
anyhow, how much time between that last line and the additional steps?
it would go like this:
Private gTimer2 as Integer
Private Sub Timer1_Timer()
Dim host_name As String
Dim time As String
Dim user As String
Dim directory As String
Timer1.enabled = false 'stop this timer.
Unload form1
'On Error Resume Next
Texttime = Now
Enabled = False
MousePointer = vbHourglass
txtResults.Text = "Working"
txtResults.SelStart = Len(txtResults.Text)
DoEvents
host_name = txtHost.Text
If LCase$(Left$(host_name, 6)) <> "ftp://" Then host_name = "ftp://" & host_name
inetFTP.URL = host_name
inetFTP.UserName = txtUserName.Text
inetFTP.Password = txtPassword.Text
time = CStr(Time)
directory = mydirectoryfile
inetFTP.Execute , "mkdir " & directory
Pause 1000 'give time for the process completing operation
inetFTP.Execute , "cd " & directory
Pause 1000
On Error Resume Next
inetFTP.Execute , "Put " & _
"c:\myfile.txt" & " & "_" & time
gTimer2 = 100 'wait 100 seconds
Timer2.enabled = true 'and start waiting...
End Sub
Private Sub Timer2_Timer()
if gTimer2 <= 0 then
Timer2.enabled = false
Kill "c:\myfile.txt"
Load form1
end if
gTimer2 = gTimer2 -1
End Sub
ASKER
it appears an runtime error 70
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello angellll,
how about the property of the timer 1 and timer 2?
i should set both to o millisecond or 1000 milliseconds?
how about the property of the timer 1 and timer 2?
i should set both to o millisecond or 1000 milliseconds?
have the timer interval set to 1000 (1 second)
and have 1 form-level variable set initially to the number of seconds you want to wait.
the timer interval would then decrease that variable, and when 0, run the procedure/work to do, and resets the interval counter.
Open in new window