Keyword

Using


Description

Makes all of the public declarations in a module (or namespace) available for inside the scope of the code as if it were defined there.

Usage

Using [Global.]identifier1.identifier2
Using [Global.]identifier

Notes

The only legal identifier for a Using statement is a module (namespace) name. The first identifier will be resolved recursively, from inner to outer scope as usual. If you would rather skip the recursive search, you may use the Global prefix.

When Using is used in code, it obeys code block scoping rules.

You can also use Using with classes and modules (Insert > Using Clause). When used in this manner, the Using applies to the entire class or module and all code contained within it.

Sample code

In the following examples, assume you have a module named Foo acting as a namespace that includes a class named Bar: Access the class without using its full namespace:

Using Foo
Var d As New Bar

Code block scoping:

If True Then
  Using Foo
  Var d As New Bar
End If

Var d As Foo.Bar ' Using statement is out of scope here

Compatibility

All project types on all supported operating systems.