Can VB.net reuse Excel's math library?

  • Thread starter Thread starter sam
  • Start date Start date
¤
¤ There are many formuls' library in Excel.
¤ Can I call them in my VB program?

The following code uses a function (XIRR) from the Analysis TookPak

Private Sub RunExcelFunction_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles RunExcelFunction.Click

Dim td(3) As Integer
Dim td1(3) As Date
td(0) = -100
td(1) = 200
td(2) = 200

td1(0) = #8/1/2000#
td1(1) = #9/1/2000#
td1(2) = #10/1/2000#

Dim objExcel As New Excel.Application()

objExcel.RegisterXLL("C:\Program Files\Microsoft
Office\Office\Library\Analysis\ANALYS32.XLL")

Dim dos As Double
dos = CType(objExcel.Run("XIRR", td, td1), Double)

objExcel.Quit()
objExcel = Nothing

End Sub


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Back
Top