Visual Basic (.NET): Difference between revisions

Content deleted Content added
m Reverted edit by 103.178.78.199 (talk) to last version by HeyElliott
Line 64:
</syntaxhighlight>
 
It prints "''Hello, World!''" on a [[command-line interface|command-line window]]. Each line serves a specific purpose, as follows:
 
<syntaxhighlight lang="vbnet">
Line 70:
</syntaxhighlight>
 
This is a module definition. Modules are a division of code, which can contain any kind of object, like constants or variables, functions or methods, or classes, but can not be instantiated as objects like classes and cannot inherit from other modules. Modules serve as containers of code that can be referenced from other parts of a program.<ref>{{cite web |url=http://msdn.microsoft.com/en-us/library/aaxss7da(VS.80).aspx |title=Module Statement |publisher=MSDN – Developer Center |access-date=January 20, 2010 |archive-date=January 9, 2010 |archive-url=https://web.archive.org/web/20100109092122/http://msdn.microsoft.com/en-us/library/aaxss7da(VS.80).aspx |url-status=live }}</ref><br />It is common practice for a module and the code file which contains it to have the same name. However, this is not required, as a single code file may contain more than one module and/or class.
<syntaxhighlight lang="vbnet">
Sub Main()
Line 81:
</syntaxhighlight>
 
This line performs the actual task of writing the output. ''Console'' is a system object, representing a command-line interface (also known as a "console") and granting programmatic access to the operating system's [[standard streams]]. The program calls the ''Console'' method ''WriteLine,'' which causes the string passed to it to be displayed on the console.
 
Instead of Console.WriteLine, one could use MsgBox, which prints the message in a dialog box instead of a command-line window.<ref>{{cite web |url=http://msdn.microsoft.com/en-us/library/3cf7t4xt(VS.80).aspx |title=Visual Basic Version of Hello, World |publisher=MSDN – Developer Center |access-date=January 20, 2010 |archive-date=January 11, 2010 |archive-url=https://web.archive.org/web/20100111152427/http://msdn.microsoft.com/en-us/library/3cf7t4xt(VS.80).aspx |url-status=live }}</ref>