Using the Microsoft Visual Basic Library


Microsoft Visual Basic Functions

One of the strengths of Visual Basic, from its beginning, was its huge library of functions. Unfortunately, even when Visual Basic was part of the Visual Studio 6.0 environment, its functions belonged only to it and to its child languages such as VBA and VBScript. When Visual Studio .NET was created, the developers of Visual Basic added all of its valuable functions and in fact made them available to the other languages that use the .NET Framework. This means that those wonderful functions are available to use in your C# programs.

The functions of Microsoft Visual Basic still belong to it and they can be called transparently in a Visual Basic application. If you want to use them in a non-Visual Basic application, you must remember to reference its library. Most (if not all) of the functions of Visual Basic are created in the Microsoft.VisualBasic.dll assembly but they might be in different namespaces. Based on this, you can include any Visual Basic function in your program. To start, you can add its reference in your application:

After doing this, you can call the desired Visual Basic function. Here are examples:

using System;

class Exercise
    static void Main()
	double Number;
	double Result;

	Console.Write("Enter a number: ");
	string strNbr = Console.ReadLine();
	if( !Microsoft.VisualBasic.Information.IsNumeric(strNbr) )
	    Number = 0.00;
	    Number = Microsoft.VisualBasic.Conversion.Val(strNbr);

	Result = Number * 2;

	Console.WriteLine("{0} * 2 = {1}", Number, Result);



Home Copyright 2008 Yevol