Click here to Skip to main content
Click here to Skip to main content

A Calculation Engine for .NET

By , 5 Jul 2012
 
Imports System.Collections
Imports System.Reflection
Imports System.Globalization

Public Class Form1

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' create calc engine
        Dim ce As New CalcEngine.CalcEngine()

        ' register custom function
        ce.RegisterFunction("Add", 2, AddressOf Add)

        ' test
        Console.WriteLine(ce.Evaluate("Add(420, 123+123)"))

    End Sub

    Private Shared Function Add(ByVal p As List(Of CalcEngine.Expression)) As Object
        Return CDbl(p(0)) + CDbl(p(1))
    End Function

End Class





By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Bernardo Castilho
Chief Technology Officer ComponentOne
United States United States
Member
No Biography provided

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 5 Jul 2012
Article Copyright 2011 by Bernardo Castilho
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid