
17/05/2004, 14:23
|
| | Fecha de Ingreso: abril-2004
Mensajes: 20
Antigüedad: 20 años, 10 meses Puntos: 0 | |
Si se puede, de hecho yo lo he hecho varias veces para tareas distintas como cargar informacion de directorios en base de datos, transmitir archivos FTP, etc.
Lo que dice MsTech.DotNet a funcionado muy bien para mi. La idea es la siguiente.
En un formulario agrega un timer y dentro del timer debe ir el codigo que se ejecutara cada cierto tiempo.
No debes controlar los lapsos de tiempo con el timer ya que son limitados, te sugiero hacerlo con otra variable (long) que pueda contener los segundos transcurridos.
Te mando un ejemplo:
Private Sub Timer1_Timer()
Dim pSegundosIntervalo As Long
Dim sMin As Long
Dim sSeg As Long
Dim sMinCount As Long
On Error GoTo ERRORES
pSegundosIntervalo = gIntervalo * 60
If mHoraInicio = 0 Then
mProcesar = True
abre_conexion
If gConexionOK = True Then
Proceso_Principal
mHoraInicio = CLng(Timer)
End If
Else
If CLng(Timer) >= mHoraInicio + pSegundosIntervalo Then
mProcesar = True
abre_conexion
If gConexionOK = True Then
Proceso_Principal
mHoraInicio = CLng(Timer)
End If
End If
End If
If gConexionOK = True Then
Cierra_Conexion
End If
If CLng(Timer) <= 2 Then
mHoraInicio = 1
End If
sMinCount = Int(((CLng(Timer) - mHoraInicio) / 60)) + 1
sMin = gIntervalo - sMinCount
sSeg = CLng(Timer) - (mHoraInicio + ((sMinCount - 1) * 60))
Barraestado.Panels(2).Text = "Próxima búsqueda en: " & "[" & Format(sMin, "00") & ":" & Format(60 - sSeg, "00") & "]"
DoEvents
ERRORES:
mProcesar = True
gConexionOK = False
Set cn = Nothing
SI no entiendes algo, preguntame. |