Wednesday, June 16, 2010

OO Hello World - VB.NET




VB.NET second in the list! Why did I decide to show VB.NET? Well, basically because:

1. Is the second most widely used programming language targeting the .NET CLR!
2. You may have already used another flavor of basic before such as: BASIC, Visual Basic and/or VBScript. So, lets show it and move on!

You can go directly to the VB.NET Info section to get some extra info about the language. Just don't forget to come back and see the code! :D


By the way, you can see my previous post here: http://carlosqt.blogspot.com/2010/06/oo-hello-world.html
where I give some details on WHY these "OO Hello World series" samples.

Version 1 (Minimal):
The minimum you need to type to get your program compiled and running.
Class Greet
    Dim name As String
    Sub New(ByVal name As String)
        Me.name = UCase(name(0)) & name.Substring(1, name.Length - 1)
    End Sub
    Sub Salute()
        Console.WriteLine("Hello {0}!", name)
    End Sub
End Class

' Greet the world!
Module GreetModule
    Sub Main()
        Dim g As New Greet("World")
        g.Salute()        
    End Sub
End Module

Version 2 (Verbose):
Explicitly adding instructions and keywords that are optional to the compiler.
Imports System
Namespace GreetProgram
    Friend Class Greet
        Private name As String
        Public Sub New(ByVal name As String)
            Me.name = UCase(name(0)) & name.Substring(1, name.Length - 1)
        End Sub
        Public Sub Salute()
            Console.WriteLine("Hello {0}!", Me.name)
        End Sub
    End Class

    ' Greet the world!
    Friend Module GreetModule
        Public Sub Main()
            Dim g As New Greet("World")
            g.Salute()
        End Sub
    End Module
End Namespace

The Program Output:
 





VB.NET Info:
“Visual Basic .NET is an evolution of the Visual Basic language that is engineered for productively building type-safe and object-oriented applications. Visual Basic enables developers to target Windows, Web, and mobile devices. As with all languages targeting the Microsoft .NET Framework, programs written in Visual Basic benefit from security and language interoperability.
This generation of Visual Basic continues the tradition of giving you a fast and easy way to create .NET Framework-based applications.” Taken from (http://msdn.microsoft.com/en-us/library/2x7h1hfk.aspx)
  
Appeared:
2002
Current Version:
Developed by:
Microsoft
Creator:
Microsoft VB Team
Influenced by:
Visual Basic
Predecessor Language
Visual Basic | BASIC
Predecessor Appeared
1991
Predecessor Creator
Alan Cooper? | John G. Kemeny and Thomas E. Kurtz
Runtime Target:
CLR
Latest Framework Target:
4.0
Mono Target:
2.6
Allows Unmanaged Code:
No
Source Code Extension:
“.vb”
Keywords:
137
Case Sensitive:
No
Free Version Available:
Yes
Open Source:
No
Standard:
No
Latest IDE Support:
Visual Studio 2010 Express
SharpDevelop 3.2/4.0 (beta)
MonoDevelop 2.2
Language Reference:
Extra Info:


No comments:

Post a Comment