9.0

138
Sub Main
X = 4
Debug.Print
"X/2=";X/2 ' 2
Debug.Print
"Start..."; ' don't print a new line
Debug.Print
"Finish" ' print a new line
End
Sub
Declare Definition
Syntax
[ | Private | Public ] _
Declare Sub
name Lib "dll name" _
[Alias "module name"] [([param
[, ...]])]
-or-
[ | Private
| Public ] _
Declare Function
name[type] Lib "dll name" _
[Alias "module name"] [([param
[, ...]])] [As type[()]]
Group
Declaration
Description
Interface to a DLL defined subroutine or function. The values of the calling arglist are assigned to the params.
Declare defaults to Public
if neither Private or Public is specified.
WARNING! Be very careful when declaring DLL subroutines or functions. If you make a mistake and declare the
parameters or result incorrectly then Windows might halt. Save any open documents before testing new DLL
declarations.
C:\ABCTemp\vbs\Err_Object.htm
Err
.LastDLLError returns the error code for that last DLL call (Windows 32 bit versions only).
Parameter Description
name This is the name of the subroutine or function bein
g
defined. If Alias "module name"
is omitted then this is the module name, too.
"dll name" This is the DLL file where the module's code is.
params A list of zero or more params that are used by the DLL subroutine or function. (Note:
A ByVal string's value may be modified by the DLL.)
"module
name"
This is the name of the module in the DLL file. If this is #number then it is the ordinal
number of the module. If it is omitted then name is the module name.
The DLL is searched for the s
p
ecified module name. If this module exists, it is used.
All As String parameters are converted from Unicode to ASCII prior to calling the
DLL and from ASCII to Unicode afterwards.
(
Use "Unicode:module name" to
p
revent
ASCII to Unicode conversion.)
If the module does not exist, one or two other module names are tried:
1) For Windows NT only: The module name with a "W" appended is tried. All As
String parameters are passed as Unicode to calling the DLL.
2) For Windows NT only: The module name with an "A" appended is tried. All As
Strin
g
p
arameters are converted from Unicode to ASCII
p
rior to callin
g
the DLL and
from ASCII to Unicode afterwards.
If none of these module names is found a run-time error occurs.
See Also: Function, Sub, Call.