Visual Basic (.NET): Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
 
(12 intermediate revisions by 7 users not shown)
Line 14:
| implementations = [[.NET Framework SDK]], [[Roslyn (compiler)|Roslyn Compiler]] and [[Mono (software)|Mono]]
| influenced_by = [[Visual Basic (classic)|Classic Visual Basic]]
| influeydhdjjsjsjjssjjjncedinfluenced = [[Microsoft Small Basic|Small Basic]], [[Mercury (RemObjects BASIC programming language)|Mercury]]
| typing = [[Dynamicly typed|Static]], [[Strong and weak typing|both strong and weak]],<ref name="option strict explicit" /> [[Type system#Safely and unsafely typed systems|both safe and unsafe]],<ref name="option strict explicit" /> [[Nominative type system|nominative]]
| dialects = Microsoft Visual Basic
Line 21:
| platform = [[.NET Framework]], [[Mono (software)|Mono]], [[.NET]]<ref>{{cite web|url=https://blogs.msdn.microsoft.com/vbteam/2018/11/12/visual-basic-in-net-core-3-0/|title=Visual Basic in .NET Core 3.0|first=Kathleen|last=Dollard|website=blogs.msdn.microsoft.com|date=November 13, 2018|access-date=November 21, 2018|archive-date=November 19, 2018|archive-url=https://web.archive.org/web/20181119070011/https://blogs.msdn.microsoft.com/vbteam/2018/11/12/visual-basic-in-net-core-3-0/|url-status=live}}</ref><ref name="devblogs-2020-03-11">{{cite web |url=https://devblogs.microsoft.com/vbteam/visual-basic-support-planned-for-net-5-0/ |title=Visual Basic support planned for .NET 5.0 &#124; Visual Basic Blog |publisher=Blogs.msdn.microsoft.com |date=2020-03-11 |access-date=2020-08-26 |archive-date=January 5, 2022 |archive-url=https://web.archive.org/web/20220105022953/https://devblogs.microsoft.com/vbteam/visual-basic-support-planned-for-net-5-0/ |url-status=live }}</ref>
| operating_system = Chiefly [[Windows]]<br/>Also on [[Android (operating system)|Android]], [[BSD]], [[iOS (Apple)|iOS]], [[Linux]], [[macOS]], [[Solaris (operating system)|Solaris]], and [[Unix]] <!-- Mono implementations, remember? -->
| license = [[Roslyn (compiler)|Roslyn]] compiler: [[MIT License]]<ref>{{Cite web|url=https://github.com/dotnet/roslyn/blob/0d04884c243978cdd609e219fdb63cb58ebec69d/License.txt|title=Dotnet/Roslyn|website=[[GitHub]]|date=November 26, 2024}}</ref><br/>
| website = {{URL|https://docs.microsoft.com/dotnet/visual-basic/}}
| file_ext = <code>.vb</code>
Line 43:
 
In addition, in Visual Basic:
* There is no unified way of defining blocks of statements. Instead, certain keywords, such as "If ... Then" or "Sub" are interpreted as starters of sub-blocks of code and have matching termination keywords such as "End If" or "End Sub".
* Statements are terminated either with a [[Colon (punctuation)|colon]] (":") or with the [[end of line]]. Multiple-line statements in Visual Basic are enabled with " _" at the end of each such line. The need for the underscore continuation character was largely removed in version 10 and later versions.<ref>{{cite web |url=https://msdn.microsoft.com/en-us/library/ff637436.aspx |title=New Features in Visual Basic 10 |date=June 3, 2010 |access-date=September 5, 2015 |archive-date=March 4, 2016 |archive-url=https://web.archive.org/web/20160304231731/https://msdn.microsoft.com/en-us/library/ff637436.aspx |url-status=live }}</ref>
* The [[equals sign]] ("=") is used in both assigning values to variables and in comparison.
Line 131:
Whether Visual Basic .NET should be considered as just another version of Visual Basic or a completely different language is a topic of debate. There are new additions to support new features, such as [[exception handling|structured exception handling]] and short-circuited expressions. Also, two important data-type changes occurred with the move to VB.NET: compared to Visual Basic 6, the <code>Integer</code> [[data type]] has been doubled in length from 16 bits to 32 bits, and the <code>Long</code> [[data type]] has been doubled in length from 32 bits to 64 bits. This is true for all versions of VB.NET. A 16-bit integer in all versions of VB.NET is now known as a <code>Short</code>. Similarly, the [[Windows Forms]] editor is very similar in style and function to the Visual Basic form editor.
 
The things that ''have'' changed significantly are the semantics—from those of an object-based programming language running on a [[deterministic]], [[reference counting|reference-counted]] engine based on [[Component Object Model|COM]] to a fully [[Object-oriented programming|object-oriented]] language backed by the [[.NET Framework]], which consists of a combination of the [[Common Language Runtime]] (a [[virtual machine]] using [[Garbage collection (computer science)#Generational GC (aka Ephemeral GC)|generational garbage collection]] and a [[just-in-time compilation]] engine) and a far larger [[class library]]. The increased breadth of the latter iswas also a problem that VB developers havehad to deal with when coming to the language, although this iswas somewhat addressed by the ''My'' feature in Visual Studio 2005.
 
The changes have altered many underlying assumptions about the "right" thing to do with respect to the performance and maintainability of applications. Some functions and libraries no longer exist; others are available, but not as efficient as the "native" .NET alternatives. Even if they compilecompiled, most converted Visual Basic 6 applications will requirerequired some level of [[refactoring]] to take full advantage of the new.NET language. DocumentationMicrosoft isprovided availabledocumentation to cover changes in thelanguage syntax, debugging applications, deployment, and terminology.<ref>{{cite web|url = http://msdn.microsoft.com/en-us/vstudio/ms788233|title = Microsoft Visual Basic 6.0 Migration Resource Center|access-date = November 9, 2014|website = [[MSDN]]|publisher = [[Microsoft]]|archive-date = November 9, 2014|archive-url = https://web.archive.org/web/20141109140433/http://msdn.microsoft.com/en-us/vstudio/ms788233|url-status = live}}</ref> A popular trade book designed to ease the transition was [[Michael Halvorson|Michael Halvorson's]] ''Microsoft Visual Basic .NET Professional Step by Step'', published in 2002 by [[Microsoft Press]].
 
==== Comparative examples ====
Line 241:
CreateObject("Sapi.Spvoice").Speak(TextBox1.Text)
End Sub
End Class
</syntaxhighlight>
 
Line 266:
 
=== 2003 (VB 7.1) ===
Visual Basic .NET 2003 was released with [[.NET Framework 1.1]]. New features included support for the [[.NET Compact Framework]] and a better VB upgrade [[wizard (software)|wizard]]. Improvements were also made to the performance and reliability of .NET IDE (particularly the [http://msdn.microsoft.com/msdnmag/issues/05/06/AdvancedBasics/default.aspx background compiler]) and runtime. In addition, Visual Basic .NET 2003 was available in the Visual Studio.NET Academic Edition, distributed to a certain number of scholars{{weasel inline|date=February 2014}} from each country without cost.
 
=== 2005 (VB 8.0) ===