Cross-platform and open-source development
The creation of open-source tools for VB.NET development has been slow compared to C#, although the Mono development platform provides an implementation of VB.NET-specific libraries and a VB.NET 8.0 compatible compiler written in VB.NET, as well as standard framework libraries such as Windows Forms GUI library.SharpDevelop and MonoDevelop are open-source alternative IDEs.
Examples
The following is a very simple VB.NET program, a version of the classic "Hello world" example created as a console application:Module Module1 Sub Main() Console.WriteLine("Hello, world!") End Sub End Module
Module Module1
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 definition.
Sub Main()
Console.WriteLine("Hello, world!")
This piece of code is a solution to Floyd's Triangle:
Imports System.Console Module Program Sub Main() Dim rows As Integer ' Input validation. Do Until Integer.TryParse(ReadLine("Enter a value for how many rows to be displayed: "), rows) AndAlso rows >= 1 WriteLine("Allowed range is 1 and {0}", Integer.MaxValue) Loop ' Output of Floyd's Triangle Dim current = 1 For row = 1 To rows For column = 1 To row Write("{0,-2} ", current) current += 1 Next WriteLine() Next End Sub ''' <summary> ''' Shadows Console.ReadLine with a version which takes a prompt string. ''' </summary> Function ReadLine(Optional prompt As String = Nothing) As String If prompt IsNot Nothing Then Write(prompt) End If Return Console.ReadLine() End Function End Module
No comments:
Post a Comment