# Alias
{: .no_toc }

Declares an alternative name for an intrinsic type, user-defined [**Type**](/tB/Core/Type.md), [**Interface**](/tB/Core/Interface.md), 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**](/tB/Core/Declare.md) 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**](/tB/Core/Type.md), an [**Interface**](/tB/Core/Interface.md), 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**](/tB/Core/Module.md) and [**Class**](/tB/Core/Class.md) blocks, alongside [**Interface**](/tB/Core/Interface.md) and [**CoClass**](/tB/Core/CoClass.md) declarations.

### Example

Aliasing intrinsic types and a user-defined type:

The **Type** goes inside a [**Module**](/tB/Core/Module.md), where a **Type** must be; the aliases go
outside it, where an **Alias** must be. Both are in the same `.twin` file:

```tb check_build projname=alias-example
Module Geometry
    Public Type POINT
        x As Long
        y As Long
    End Type
End Module
```

```tb check_build projname=alias-example slot=file
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:

```tb check_build projname=alias-example
Dim p As POINT
Dim q As POINTAPI
p = q   ' OK -- no type mismatch.
```

### See Also

- [**Type** statement](/tB/Core/Type.md)
- [**Interface** statement](/tB/Core/Interface.md)
- [**CoClass** statement](/tB/Core/CoClass.md)
- [Alias Types](/Features/Language/Alias-Types.md)
