article

Left(String,?) Right(String,?)

Email
Submitted on: 1/1/2015 7:38:00 AM
By: Brandon Robinson (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB.NET
Views: 1774
 
     Alrighty, Just like everyone else. I am just a little frustrated trying to find all my old fuctionality from VB6 in VB.NET. So when I ran across this I thought I would post it.

 
				

Visual Basic Language Reference

Imports Statement

<---->

Imports namespace names from referenced projects and assemblies. Also imports namespace names defined within the same project as the file in which the statement appears.

Imports [ aliasname = ] namespace [ . element ]

Parts

aliasname
Optional. The name by which namespace may also be known or referred to. When the Imports statement does not include aliasname, the elements defined within the specified namespace can be accessed within the file without qualification. When aliasname is specified, it must be used as a qualifier for the names contained in the namespace. Aliases are useful when you need to use items with the same name that are declared in one or more namespaces.
namespace
Required. The name of the namespace being imported. The namespace can be any number of nesting levels deep.
element
Optional. The name of an element declared in the namespace. The element can be an enumeration, structure, class, or module.

Remarks

Each file can contain any number of Imports statements. Imports statements must be placed before any declarations, including Module or Class statements, and before any references to identifiers.

The scope of the elements made available by an Imports statement depends on how specific you are when using the Imports statement. For example, if only a namespace is specified, all uniquely named members of that namespace, and members of modules within that namespace, are available without qualification. If both a namespace and the name of an element of that namespace are specified, only the members of that element are available without qualification.

It is not permitted to define a member at module level with the same name as an import alias.

Example

The following example imports the Microsoft.VisualBasic.Strings class and assigns an alias, Str, that can be used to access the Left method.

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


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.