Declare statement
Declare Sub procedurename Lib Libname$ [Alias aliasname$][( argument list )]
Declare Function procedurename Lib Libname$ [Alias aliasname$] [( argument list )][As Type]
The Declare statement makes a reference to an external procedure in a Dynamic Link Library (DLL).
The procedurename parameter is the name of the function or subroutine being called.
The Libname parameter is the name of the DLL that contains the procedure.
The optional Alias aliasname clause, is used to supply the procedure name in the DLL if different from the name specified on the procedure parameter. When the optional argument list needs to be passed the format is as follows:
([ByVal] variable [As type] [,ByVal] variable [As type] ]…])
The optional ByVal parameter specifies that the variable is [passed by value instead of by reference (see “ByRef and ByVal” in this manual). The optional As type parameter is used to specify the data type. Valid types are String, Integer, Double, Long, and Variant.
Refer to Variable types for more information.
If a procedure has no arguments, use double parentheses () only to assure that no arguments are passed:
Declare Sub OntTime Lib “Check” ()
Note
BlueZone Basic extensions to the declare statement. The following syntax is not supported by Microsoft Visual Basic.
Declare Function procedurename App [Alias aliasname$] [(argument list)][As Type]
This form of the Declare statement, makes a reference to a function located in the executable file located in the application where BlueZone Basic is embedded.
Example
Declare Function GetFocus Lib "User" () As Integer
Declare Function GetWindowText Lib "User" (ByVal hWnd%, ByVal Mess$, ByVal cbMax%) _ 
As Integer
 
Sub Main
   Dim hWindow%
   Dim str1 As String *51
   Dim str2 As String * 25
 
   hWindow% = GetFocus()
   print "GetWindowText returned: ", GetWindowText( hWindow%, str1,51 )
   print "GetWindowText2 returned: ", GetWindowText( hWindow%, str2, 25)
   print str1
   print str2
End Sub