VB.NET 1.1 Tutorial - The Imports KeywordThe Imports Keyword is used to import a namespace name from a referenced project or assembly. It can also be used to give an alias to a name that is declared in one or more namespaces. Imports namespace or Imports aliasname = namespace All Imports statements should be placed at the top of the page of code. We have already seen how to use the Imports statement in the Hello Mum! console application to import namespaces from the standard .Net dll's. The following example, taken from the msdn library, shows the method of using aliases. Imports Str = Microsoft.VisualBasic.Strings
' Place Imports statements at the top of your program
Class MyClass1
Sub ShowHello()
MsgBox(Str.Left("Hello World", 5)) ' Displays the word "Hello"
End Sub
End Class
ReferencesFor more information on the Imports Statement, visit MSDN at microsoft here. What Next?Return to the Tutorial Contents. |