DoEvents Function

Transfers control to the operating system during macro execution, so that it can process the events in waiting.

āύ⧋āϟ āφāχāĻ•āύ

DoEvents provides compatibility with VBA. It always returns 0. Using it in LibreOffice is not necessary.


Syntax:


        [Call] DoEvents[()] As Integer
    

Example:

Both examples set a progressive counter on the first cell of a newly opened Calc document.


      Sub DoEventsExample
          Dim i As Long, sheet As Object, cell As Object
          sheet = ThisComponent.Sheets.getByIndex(0) ' sheet 1
          cell = sheet.getCellByPosition(0,0) ' cell A1
          For i = 1 To 20000
              cell.setString(Str(i))
              DoEvents
          Next i
      End Sub ' DoEventsExample
    

      Sub DoEvents_example
          Dim i As Long, ui As Object
          GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
      	Set ui = CreateScriptService("SFDocuments.Calc", ThisComponent)
          For i = 1 To 20000
              ui.SetValue("A1", i)
              DoEvents
          Next i
          ui.Dispose()
      End Sub ' DoEvents_example
    
Please support us!

Please support us!