Views

Histats

Vitrine

VBA Tips: Função de Delay

Inline image 1

As funções de delay são muito úteis quando precisamos desacelerar algum processamento ou funcionalidade em detrimento de esperarmos conexões de banco de dados, processos pendentes fora a nossa aplicação e por aí afora. Divirtam-se!
  Public Function Delay(dblInterval As Double)
   '----------------------------------------------------
   ' Name: Delay
   ' Purpose: Generic delay code
   ' Inputs: dblInterval As Double
   ' Author: Arvin Meyer
   ' Date: January 2, 1999
   ' Comment: 
   '----------------------------------------------------
  On Error GoTo Err_Delay
  Dim Timer1 As Double
  Dim Timer2 As Double
  Timer1 = Timer()
    Do Until Timer2 >= Timer1 + dblInterval
        DoEvents
        Timer2 = Timer()
    Loop
Exit_Delay:
 Exit Function
Err_Delay:
 Select Case Err
 Case Else
  MsgBox Err.Description
  Resume Exit_Delay
 End Select
End Function

Tags: VBA, Office, Tips, delay, wiat, espera

Inspiration: Accessmvp.com

LinkWithinBrazilVBAExcelSpecialist

Related Posts Plugin for WordPress, Blogger...