Visual Basic (.NET): Difference between revisions

Content deleted Content added
Line 157:
* All procedure calls must be made with parentheses in VB.NET, whereas in Visual Basic 6 there were different conventions for functions (parentheses required) and subs (no parentheses allowed, unless called using the keyword <code>Call</code>).
* The names <code>Command1</code> and <code>Button1</code> are not obligatory. However, these are default names for a command button in Visual Basic 6 and VB.NET respectively.
* In VB.NET, the <code>Handles</code> keyword is used to make the sub <code>Button1_Click</code> a handler for the <code>Click</code> event of the object <code>Button1</code>. In Visual Basic 6, event handler subs must have a specific name consisting of the object's name ("{{code|Command1"}}), an underscore ("{{code|_"}}), and the event's name ("{{code|Click"}}, hence "{{code|Command1_Click"}}).
* There is a function called <code>MessageBox.Show</code> in the <code>Microsoft.VisualBasic</code> namespace which can be used (instead of <code>MsgBox</code>) similarly to the corresponding function in Visual Basic 6. There is a controversy<ref>{{cite web|url=https://www.microsoft.com/en-us/download/details.aspx?id=55979|title=Visual Studio 2003 Retired Technical documentation|website=Microsoft Download Center|access-date=July 24, 2018|archive-date=December 30, 2014|archive-url=https://web.archive.org/web/20141230014657/http://msdn.microsoft.com/en-us/library/aa291820(VS.71).aspx|url-status=live}}</ref> about which function to use as a best practice (not only restricted to showing message boxes but also regarding other features of the <code>Microsoft.VisualBasic</code> namespace). Some programmers prefer to do things "the .NET way", since the Framework classes have more features and are less language-specific. Others argue that using language-specific features makes code more readable (for example, using <code>int</code> (C#) or <code>Integer</code> (VB.NET) instead of <code>System.Int32</code>).
* In Visual Basic 2008, the inclusion of <{{code>|2=vbnet|ByVal sender as Object}}, {{code|2=vbnet|ByVal e as EventArgs</code>}} has become optional.
 
The following example demonstrates a difference between Visual Basic 6 and VB.NET. Both examples close the [[active window]].