Alias

Declares an alternative name for an intrinsic type, user-defined Type, Interface, or another Alias. The alias and the original type are interchangeable — assigning between them is not a type mismatch. Comparable to typedef in C/C++.

Note

The Alias statement is a twinBASIC extension. It has no equivalent in classic VBA, where the only use of the Alias keyword is to name a DLL entry point in a Declare statement.

Syntax:

[ Public | Private ] Alias aliasname As type

Public
optional The alias is exported to the type library of an ActiveX DLL or control, so consumers in other projects see aliasname itself.
Private
optional The alias is visible only within the project. Usages of a Private alias are replaced with the underlying type during compilation, so aliasname never appears in the project’s type library.
aliasname
The name of the alias. Must be a valid twinBASIC identifier.
type
The original type. May be an intrinsic type, a user-defined Type, an Interface, or another Alias.

Alias statements are valid only in .twin source files (not legacy .bas or .cls files), and must appear at file scope — outside of Module and Class blocks, alongside Interface and CoClass declarations.

Example

Aliasing intrinsic types and a user-defined type:

The Type goes inside a Module, where a Type must be; the aliases go outside it, where an Alias must be. Both are in the same .twin file:

Module Geometry
    Public Type POINT
        x As Long
        y As Long
    End Type
End Module
Public Alias POINTAPI As POINT

Public Alias CBoolean As Byte

Public Alias KAFFINITY As LongPtr

A variable declared with the alias and a variable declared with the original type are interchangeable:

Dim p As POINT
Dim q As POINTAPI
p = q   ' OK -- no type mismatch.

See Also