Description of API Call Keywords

VB 6.0


[Public | Private] Declare Sub|Function name Lib _
"libname" [Alias "aliasname"] [([arglist])] [As type]


Public or Private

This difines the scope of the declaration. If it's declared Public, then any procedure within your project can call the procedure; otherwise, only the module where the declaration was made can use the procedure. Note that you can't make an API Public if it's declared in a form or classs module; this can only be done in code modules. If you omit this keyword, VB will default the declaration to be Public.

Declare

This keyword is used for API calls only. Standard procedures that you create in VB don't use this keyword.

Sub or Function

This lets VB know if the procedure will return a value (Funtion) or not (Sub).

name

This is the name that you will use in your VB code to call the procedure. This may or may not be the same name that the DLL users for the procedure.

Lib

A keyword required when making an API declaration.

libname

This is the file name of the DLL. You can either give a full file path (like c:\Windows\System\kernel32.dll) or just the file name (like kernel32). Be foreworned, though. If you hard-code a full file path in your project. make sure that the DLL file stays there. Depending on a multitude of issues (such as installing the application, the OS the user has, etc), the file may not be wheree it was when you were developing the system, which would cause an error to occur when the API calll was made.

Alias

This isn't required for the declaration, but it can be useful when procedure-naming conflicts arise. For example, if the API call is named raiseRent and you have a call within your application with the same name, you can name the API call APIRaiseRent and use the Alias keyword to define the actual name of the call. A classic example of this is the SetFocus. API call. This definitely conflicts with VB's SetFocus method.

Aliasname

If the Alias keyword was used, you have to give either the procedure name or its ordinal number.

arglist

This is where all of the arguments that the procedure needs go, if any exist. Note that the names of the arguments don't matter, but the way the variable is passed into the API (by value or by reference) along with the data type definitely matters.

As type

If the API call is a function, then this will define the return type.




VB Page

HOME



Last update:  7-8-2003 at 8:45pm