[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Passing Function Values from ASP to VB Dll Function Help

I keep getting type mismath  Type mismatch: 'IRRCalc'.  Here is what I have I need to pass in array values and a percentage and this is not working for me I keep getting errors:

Public Function IRRCalc(ByRef Values() As Double, ByRef Guess As Double) As String
IRRCalc = Format(IRR(Values(), Guess) * 100, "#0.00") & "%"
End Function

ASP Page:
<%@ Language=VBScript %>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

Dim objCalcVal, RetVal
Dim arrIRR(3),valGuess
arrIRR(0) = CDBL(-2465399)
arrIRR(1) = CDBL(1725956)
arrIRR(2) = CDBL(1686970)
arrIRR(3) = CDBL(1599299)
valGuess = CDBL(0.1)
Set objCalcVal = Server.CreateObject("FinancialCalcs.clsFinancialCalcs")
RetVal = objCalcVal.IRRCalc(arrIRR,valGuess)
Response.Write RetVl

1 Solution
Anthony PerkinsCommented:
That is because and array of variants (arrIRR) is not the same as an array of doubles (Values), or for that matter a variant (valGuess) the same as a double (Guess).
sbornstein2Author Commented:
Is there a way I can pass it the correct way to get the value from the DLL?
Anthony PerkinsCommented:
I would suggest changing your DLL to be compatible with ASP.  Is that not an option?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

sbornstein2Author Commented:
Sure just not sure how to change that, I thought this would work.
Pass the values separately rather than as an array.

1.  When you get an error from a dll, the line number will typically never be correct.   You must also look for errors elsewhere in your code.

2.  Build the array in your code.  Somewhere in the general declarations of the class, put

dim dblArr() as double
dim dblArrUsed as boolean
'add the function
sub AddDbl(sVar as vaiant)
  dim i as long
  if isnumeric(sVar) then
    if dblArrUsed then
      i = ubound(dblArr) + 1
      redim preserve dblArr(i)
      dblArr(i) = cdbl(sVar)
      redim dblArr(0)
      dblArr(0) = cDbl(sVar)
    end if
  end if
end sub

'then don't pass the array any more, but use the one in the class object as well.
i think this code should solve your problem

Public Function IRRCalc(ByRef Values() As Variant, ByRef Guess As Variant) As String
IRRCalc = Format(IRR(Values(), Guess) * 100, "#0.00") & "%"
End Function

sbornstein2Author Commented:
No dice:
Public Function IRRCalc(ByRef Values() As Variant, ByRef Guess As Variant) As String
IRRCalc = Format(IRR(Values(), Guess) * 100, "#0.00") & "%"
End Function

does not work the IRR Function is looking for a Double for some reason coming in so it does not compile on IRR(VALUES() it highlights Values() nest to IRR.
sbornstein2Author Commented:
hpdvs2 how then do I pass it in through the ASP and then use the function with what your suggesting?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now