Visual Basic Language Samples
Updated: May 2011
These samples demonstrate various Visual Basic language features.
To access samples from Visual Studio
On the Help menu, click Samples.
In the Samples on Disk section of the readme file, click local Samples folder. By default, the samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\1033 or drive:\Program Files (x86)\Microsoft Visual Studio 10.0\Samples\1033.
Right-click the .zip file that contains the samples you want to open and then click Extract All to extract the samples to a folder of your choice.
For the most current samples, go to the Visual Basic Samples Web site.
Microsoft provides the included samples "AS IS" with no warranties. The code in the samples is provided just to illustrate concepts. The provided code may not meet security requirements for any specific environment. We recommend that you add security and error-handling code to your projects to make them as secure and robust as you deem appropriate.
API Call Sample
Demonstrates calling Win32 API functions to enumerate and control processes and windows, and to query and change system settings.
Creates arrays of Integer and Object values, and sorts and searches arrays.
Auto-Implemented Properties Sample
Contains a source file that uses auto-implemented properties, and a similar source file that uses standard (or expanded) property syntax.
Collection Initializers Sample
Demonstrates how to use collection initializer syntax to create arrays and collections.
Demonstrates the covariance and contravariance features, showing how to use the In and Out keywords when you declare generic interface type parameters.
Custom Exception Sample
Demonstrates custom exceptions and global exception handling.
DateTime and TimeSpan Sample
File System Sample
Demonstrates the how to use FileSystem methods.
Shows how to create various generic collections and how to manipulate them.
Implicit Line Continuation Sample
Contains a source file that uses implicit line continuations, and a similar source file that uses explicit line continuations.
Statement Lambdas Sample
Demonstrates statement lambdas, which enable you to declare procedures that have multiple statements inside other procedures.
String Formatting Sample
Shows how to display numeric, date/time, and enumeration values as strings by using a variety of standard and custom culture-specific format codes.
Demonstrates how to use String methods.
Shows how to handle exceptions in applications by using the Try...Catch...Finally Statement (Visual Basic).
Visual Basic Language Features Sample
Highlights several Visual Basic language features, including generics, operator overloading, and the Using keyword.
Visual Basic Object-Oriented Programming Sample
Demonstrates the options available with object-oriented programming.
XML Comments Sample
Demonstrates the XML comment feature of Visual Basic.