Thursday, March 19, 2020

VB.NET Imports Statement Versus References

VB.NET Imports Statement Versus References The actual effect of the Imports statement in VB.NET is often a source of confusion for people learning the language. And the interaction with VB.NET References makes for even more confusion. Were going to clear that up in this Quick Tip. Heres a brief summary of the whole story. Then well go over the details. A Reference to a VB.NET namespace is a requirement and must be added to a project before the objects in the namespace can be used. (A set of references is automatically added for the different templates in Visual Studio or VB.NET Express. Click Show All Files in  Solution Explorer to see what they are.) But the Imports statement is not a requirement. Instead, its simply a coding convenience that allows shorter names to be used. Now lets look at an actual example. To illustrate this idea, were going to use the System.Data namespace - which provides ADO.NET data technology. System.Data is added to Windows applications as a Reference by default using the VB.NET Windows Forms Application template. Adding a Namespace in the References Collection Adding a new namespace to the References collection in a project makes the objects in that namespace available to the project as well. The most visible effect of this is that the Visual Studio Intellisense will help you find the objects in popup menu boxes. If you attempt to use an object in your program without a Reference, the line of code generates an error. The Imports statement, on the other hand, is never required. The only thing it does is allow the name to be resolved without being fully qualified. In other words (emphasis added to show the differences). Imports System.Data Public Class Form1   Ã‚  Ã‚  Inherits System.Windows.Forms.Form   Ã‚  Ã‚  Private Sub Form1_Load( ...   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Dim Test As OleDb.OleDbCommand   Ã‚  Ã‚  End Sub End Class and Imports System.Data.OleDb Public Class Form1   Ã‚  Ã‚  Inherits System.Windows.Forms.Form   Ã‚  Ã‚  Private Sub Form1_Load( ...   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Dim Test As OleDbCommand   Ã‚  Ã‚  End Sub End Class are both equivalent. But ... Imports System.Data Public Class Form1   Ã‚  Ã‚  Inherits System.Windows.Forms.Form   Ã‚  Ã‚  Private Sub Form1_Load( ...   Ã‚  Ã‚  Ã‚  Ã‚  Ã‚  Dim Test As OleDbCommand   Ã‚  Ã‚  End Sub End Class results in a syntax error (Type OleDbCommand is not defined) because of the Imports namespace qualification System.Data doesnt provide enough information to find the object OleDbCommand. Although the qualification of names in your program source code can be coordinated at any level in the apparent hierarchy, you still have to pick the right namespace to reference. For example, .NET provides a System.Web namespace and a whole list of others starting with System.Web ... Note There are two entirely different DLL files for the references. You DO have to pick the right one because WebService isnt a method in one of them.

Tuesday, March 3, 2020

Abbreviation with Names and of Titles

Abbreviation with Names and of Titles Abbreviation with Names and of Titles Abbreviation with Names and of Titles By Mark Nichol This post outlines major conventions regarding the use of initials and abbreviations in association with people’s names. Periods are used with initials in names (â€Å"W. E. B. Du Bois†) unless someone is referred to exclusively by his or her initials (â€Å"FDR†). Note, too, that in formal writing, a space separates each initial used in a full name, as shown in the first example here, though periodicals and other less formal publications generally omit the spaces (â€Å"W.E.B. Du Bois†). Civil or military titles are often abbreviated before a full name but not before a surname alone (â€Å"Sen. Elizabeth Warren,† but â€Å"Senator Warren†), although inclusion of the title with the surname is generally not necessary. (In this case, Warren alone is suitable for subsequent references to the person after the introduction of her by her full name.) In situations in which space is at a premium, as in a chart or table, abbreviation can be applied more liberally, and in that case it’s best to be consistent within the graphic element even if sufficient space is available with some names but not others. Social titles such as Mr. and Ms. are rarely used in published writing anymore, except in quoted material, and are redundant when initials designating an academic degree or professional attainment follow a name. (For example, in the phrase â€Å"Dr. Jane Smith, MD,† Dr. and MD are two ways of expressing the same information.) Note that such references as MD, or CPA (for â€Å"certified public accountant†), are appended to a name enclosed between commas, but when abbreviations such as Jr. and III follow a name, no intervening punctuation is necessary (as in â€Å"John Smith Jr. was honored at the ceremony†). In narrative, spell out titles such as â€Å"the Reverend† and â€Å"the Honorable† before a full name (and do use the article), but they can be abbreviated as Rev. or Hon. (without the article) in a list. When referring to a saint, spell out that word unless space is limited; St. is the correct abbreviation. (When the word or abbreviation appears in a person’s name, honor the style that person uses.) Most titles specifying one’s role in a company or organization are generally not abbreviated, but one exception is often made for the most senior executive, the CEO (â€Å"chief executive officer†). That title is often abbreviated without a full spelling on first reference, though titles for others, such as â€Å"chief operating officer,† who work in what is known as the C-suite (because the first word of the job titles for these people is chief, abbreviated with a capital c) are usually spelled out. (Specialized publications catering to an audience familiar with such titles often abbreviate them on first reference, however.) Want to improve your English in five minutes a day? Get a subscription and start receiving our writing tips and exercises daily! Keep learning! Browse the Style category, check our popular posts, or choose a related post below:Definitely use "the" or "a"60 Synonyms for â€Å"Trip†Dissatisfied vs. Unsatisfied