NCalc VB.NET error Function not found

Topics: Help
Jul 29, 2013 at 10:33 PM
Edited Jul 29, 2013 at 10:38 PM

Firstly a big thanks to the author of this great library !
I have just transformed your examples code into VB.NET (framwork 4, VS 2010), here is my code :
 Public Sub calcul()
        Dim exp As New Expression("Lines(3,7)")

        AddHandler exp.EvaluateFunction, Sub(name As String, args As FunctionArgs)
              Dim nbArgs As Integer = args.Parameters.Count
              If name = "Lines" Then
                    If nbArgs = 1 Then
                          MsgBox("One line : " & args.Parameters.First.ToString)
                    ElseIf nbArgs = 2 Then
                          MsgBox("One range : from line " & args.Parameters.First.Evaluate.ToString & " to line " & args.Parameters.Last.Evaluate.ToString)
                          MsgBox("Several lines : ")
                    End If
              End If
       End Sub
End Sub
The code compiles and seams to works because at the launching of my app, a dialog appears with the message "One range : from line 3 to line 7". But immediatly after clicking OK, the program stops itself and raises an error just near the line :
The error message that appears is :
Function not found
Parameter name: Lines
I don't understand very well what it happened and I count on you to help me to resolve this issue.

Thank you very much!!

Jul 30, 2013 at 1:59 PM

Well, I have resolved the problem. In fact the args.Result variable was not valued by the delegate... So if you have the same issue, you have to value the args result object before the procedure end.