Name

Declare Statement

Synopsis

Syntax for subroutines:
[accessmodifier] Declare [Ansi|Unicode|Auto] Sub name_
    Lib "libname" [Alias "aliasname"] [([arglist])]

Syntax for functions:
[accessmodifier] Declare [Ansi|Unicode|Auto] Function name _
    Lib "libname" [Alias "aliasname"] [([arglist])] [As type]
accessmodifier optional; Keyword

accessmodifier can be any one of the following: Public, Private, Protected, Friend, or Protected Friend. The following table describes the effects of the various access modifiers. Note that direct access refers to accessing the member without any qualification, as in:

classvariable = 100

and class/object access refers to accessing the member through qualification, either with the class name or the name of an object of that class.

Direct access scope

Class/objectaccess scope

Private

Declaring class

Declaring class

Protected

All derived classes

Declaring class

Friend

Derived in-project classes

Declaring project

Protected Friend

All derived classes

Declaring project

Public

All derived classes

All projects

Ansi optional; Keyword

Converts all strings to ANSI values.

Unicode optional; Keyword

Converts all strings to Unicode values.

Auto optional; Keyword

Converts the strings according to .NET rules based on the name of the method (or the alias name, if specified). If no modifier is specified, Auto is the default.

name required; String literal

Any valid procedure name. Note that DLL entry points are case sensitive. If the aliasname argument is used, name represents the name by which the function or procedure is referenced in your code, while aliasname represents the name of the routine as found in the DLL.

Lib required; Keyword

Indicates that a DLL or code resource contains the procedure being declared.

libname required; String literal

Name of the DLL or code resource that contains the declared procedure.

Alias optional; Keyword

Indicates that the procedure being called has another name in the DLL. This is useful when the external procedure name is the same as a keyword. You can also use Alias when a DLL procedure has the same name as a public variable, constant, or any other procedure in the same scope. Alias is also useful if any characters in the DLL procedure name aren’t allowed by VB.NET naming conventions.

aliasname optional; String literal

Name of the procedure in the DLL or code resource. If the first character is not a number sign (#), aliasname is the name of the procedure’s entry point in the DLL. If # is the first character, all characters that follow must indicate the ordinal number of the procedure’s entry point.

arglist optional

List of variables representing arguments that are passed to the procedure when it is called.

type optional; Keyword

Data type of the value returned by a Function procedure; may be Byte, Boolean, Char, Short, Integer, Long, Single, Double, Decimal, Date, String, Object, or any user-defined type. Arrays of any type cannot be returned, but an Object containing an array can.

Description

Used at module level to declare references to external procedures in a dynamic-link library (DLL).

The data type you use in the As clause following arglist must match that returned by the function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset