PV function and porting VB6 to C #

I am working on porting the classic VB6 code to C # and just stumbled upon using the PV function.

I feel wrong, including a link to the Microsoft.VisualBasic assembly. Is this something that is usually done, or should I explore additional options. The next idea that appears in my head explores this PV function in Reflector.

+6
c # vb6 vb6-migration
source share
3 answers

Using Microsoft.VisualBasic from C # and VB.NET has been discussed in detail in this matter . The Microsoft.VisualBasic namespace is fully supported , and will work as long as .Net is nearby. There is no reason to avoid it.

EDIT:. Saying that during input, the other answers to this question are an incorrect re-evaluation of the function and an unsupported library from the one-person code gallery. Come on guys, this will take the real main event for Microsoft to give up the financial functions of VB.

This is another story for Microsoft.VisualBasic.Compatibility , which is intended solely for use by the VB6 update wizard, EDIT is now marked as deprecated in .Net 4 (my prediction came true), and it cannot be used for new development. There would be some advantages in eliminating the links to this, but personally, I will probably try to create a fully working port that first references .NET 3.5.

+10
source share

Pretty straightforward for replication in C #

  public static double PV(double Rate, int nPer, double Pmt, double FV, bool Type) { double ann = Math.Pow(1 + Rate, nPer); return -(FV + Pmt * (1 + (Type ? Rate : 0)) * ((ann - 1) / Rate)) / ann; } 

Just reformatting the formula Microsoft provides .

+3
source share

You can use this library which duplicates excel functions in f #

Library

It has a PV, which represents the present value. I used it once or twice. Just omit it and add the link.

+1
source share

All Articles