Menu

keywords-using

Will Pittenger

Creates a block of code where a variable declared just after the using keyword or anywhere in the block will go out of scope at the end of the block. It's the equivalent of using braces in C/C++/C#/Java to force variables out of scope at the end of the braces block.

So if you wanted this C++ equivalent:

void MyFunc()
{
  // Some block of code
  {
     int i = 3;
  }
  // i is now out of scope
}

do this:

command myCommand
  ' Some block of code

  using var int = 3 ' you can declare a comma delimited list of variables, each with their own **var** declaration
    ' Or declare something here

  ' i is now out of scope as the **using** block is over.

If you declare multiple variables on the same line, treat each one as a completely independent declaration. It isn't like C where you list the type once and then a comma delimited list of identifiers. Each entry stands on its own.

using var i% = 3, var s% = "test", var f# = 3.43
  ' Do something with those.

Related

Wiki: Keywords
Wiki: Scope rules