uFoAm‖

9FWFc‖Declare Statement

doBTG‖Declares and defines a subroutine in a DLL file that you want to execute from LibreOfficeDev Basic.

zD3YU‖See also: FreeLibrary

FVEx2‖Syntax:


vmWCD‖Declare {Sub | Function} Name Lib "Libname" [Alias "Aliasname"] [Argumentlist] [As Type]

WADQ4‖Parameters:

PpcP9‖ Name: A different name than defined in the DLL, to call the subroutine from LibreOfficeDev Basic.

kn7cx‖ Aliasname: Name of the subroutine as defined in the DLL.

JYFGa‖ Libname: File or system name of the DLL. This library is automatically loaded the first time the function is used.

PREVE‖ Argumentlist: List of parameters representing arguments that are passed to the procedure when it is called. The type and number of parameters is dependent on the executed procedure.

c6CFQ‖ Type: Defines the data type of the value that is returned by a function procedure. You can exclude this parameter if a type-declaration character is entered after the name.

Warning Icon

SDREj‖To pass a parameter to a subroutine as a value instead of as a reference, the parameter must be indicated by the keyword ByVal.


EFSA4‖Example:


Declare Sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" ( Long )
Sub ExampleDeclare
Dim lValue As Long
    lValue = 5000
    MyMessageBeep( lValue )
    FreeLibrary("user32.dll" )
End Sub

mBuJC‖Example 2


  eUDfk‖REM When passing arrays by reference, do not specify the type of its elements.
  Declare Function GetDiag Lib "C:\\...\\Math.dll" _
     Alias "GetDiag" ( _
     ByVal varName As String, _
     A, _
     ByVal len As Long, _
     ByVal FunctionName As String, _
     B, _
     C) As Long
Sub MyCode
  Dim A(100) As Long, B(100) As Long, C(100) As Long ' arrays
  R = GetDiag("f", A, 100, "g", B, C)
  Print R
End Sub
Please support us!

Please support us!