Home

The Microsoft Visual Basic Library

     

Introduction to the C# Library

One of the strengths of Visual Basic, from its beginning, was its huge library of functions. Unfortunately, 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 Microsoft Visual Studio .NET (2002) 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 for use in your C# programs.

The Visual Basic language is one of those languages that have their own library of functions and classes. If you want to use that library in a non-Visual Basic application, you must reference it in your application. The functions of the Visual Basic language are created in the Microsoft.VisualBasic.dll library.

 

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.

ApplicationApplication: Using the Visual Basic Library

  1. To start a new project, on the main menu, click File -> New Project...
  2. In the middle list, click Empty Project
  3. Change the Name to DepartmentStore7 and click Add
  4. On the main menu, click Project -> Add Reference...
  5. Cclick the .NET tab
  6. In the list, click Microsoft.VisualBasic
     
    Add Referencce
  7. Click OK
  8. In the Solution Explorer, right-click DepartmentStore7 -> Add -> New Item...
  9. In the middle list, click Code File
  10. Change the name to CreditCardEvaluation and click Add
  11. Change the file as follows:
    using System;
    
    public class Payroll
    {
        static int Main()
        {
            double presentValue = 500.00d;
            double interestRate = 0.08627; // 8.627%
            double numberOfPayments  = 24; // 2 years * 12 months
            double monthlyPayment = 0.00d;
    
            monthlyPayment = Microsoft.VisualBasic.Financial.Pmt(interestRate,
                                                                 numberOfPayments,
                                                                 -presentValue);
            Console.WriteLine("==========================");
            Console.WriteLine("=-=  Department Store  =-=");
            Console.WriteLine("-- Store Card Estimate --");
            Console.WriteLine("--------------------------");
            Console.Write("Starting Balance: ");
            Console.WriteLine(Microsoft.VisualBasic.Strings.FormatNumber(presentValue));
            Console.Write("Interest Rate:    ");
            Console.WriteLine(Microsoft.VisualBasic.Strings.FormatPercent(interestRate));
            Console.Write("Monthly Payment:  ");
            Console.WriteLine(Microsoft.VisualBasic.Strings.FormatCurrency(monthlyPayment));
            Console.WriteLine("==========================");
    
            System.Console.ReadKey();
            return 0;
        }
    }
  12. Execute the application. This would produce:
    ==========================
    =-=  Department Store  =-=
    -- Store Card Estimate --
    --------------------------
    Starting Balance: 500.00
    Interest Rate:    8.63%
    Monthly Payment:  $50.00
    ==========================
  13. Press any key to close the DOS window and return to your programming environment
 

Home Copyright © 2010-2011 FunctionX