Monday, August 11, 2008

VB.NET Tutorial

1. 1. Introduction

1. 1. 1. How to compile and run the code in this tutorial

Go to: Start->Programs->Visual Studio.NET->Visual Studio.NET Tools-> Visual Studio.NETCommand Prompt, and type:
c:\examples>vbc example1.vb.

1. 1. 2. Simple Visual Basic program

Module Tester
Sub Main()
Console.WriteLine("Welcome to Visual Basic!")
End Sub
End Module

1. 1. 3. Writing line of text with multiple statements

Module Tester
Sub Main()
Console.Write("Welcome to ")
Console.WriteLine("Visual Basic!")
End Sub
End Module

1. 2. Console Read

1. 2. 1. Read a single character

Module Module1
Sub Main()
Dim strChar As String
Console.Write("Enter a character: ") strChar = Console.ReadKey.KeyChar 'strChar = Console.ReadKey(True).KeyChar Console.WriteLine() Console.WriteLine("You just entered {0}.", strChar) End SubEnd Module