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.
Application:
Using the Visual Basic Library
|
|
- To start a new project, on the main menu, click File -> New
Project...
- In the middle list, click Empty Project
- Change the Name to DepartmentStore7 and click Add
- On the main menu, click Project -> Add Reference...
- Cclick the .NET tab
- In the list, click Microsoft.VisualBasic
- Click OK
- In the Solution Explorer, right-click DepartmentStore7 -> Add -> New
Item...
- In the middle list, click Code File
- Change the name to CreditCardEvaluation and click
Add
- 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;
}
}
- Execute the application. This would produce:
==========================
=-= Department Store =-=
-- Store Card Estimate --
--------------------------
Starting Balance: 500.00
Interest Rate: 8.63%
Monthly Payment: $50.00
==========================
- Press any key to close the DOS window and return to your programming
environment
|
|