dannyres Posted October 26, 2003 Posted October 26, 2003 Hey guys i have a problem. Im trying to make a program where the user can enter something like 5 + 5 * 10 / 50 in a textbox and my program will calculate it but i cant work out how... anyone got any ideas on how todo this? Dan Quote
*Experts* mutant Posted October 26, 2003 *Experts* Posted October 26, 2003 You would have to parse the string and multiply/divide/add/subtract - or whatever you want to do - individual parts of it. And then of course comes the order of operatins :) So lets say you would first search for a parenthesis and then parse whats inside of it. Either regular expressions or String methods like SubString, IndexOf, etc. would be a good way to do it. Quote
*Gurus* Derek Stone Posted October 26, 2003 *Gurus* Posted October 26, 2003 Or you could just chuck it into a CodeDOM template and execute it directly. Probably be a lot easier. Quote Posting Guidelines
dannyres Posted October 27, 2003 Author Posted October 27, 2003 (edited) Derek Stone how would i go about that? Dan EDIT: Ok i think i got what you ment and this is what ive done: I have a text file with this in it: Imports System Imports System.Reflection Imports System.Runtime.InteropServices <Assembly: AssemblyTitle("Calculate")> <Assembly: AssemblyDescription("Calculator for Codename: Dashboard")> <Assembly: AssemblyConfiguration("")> <Assembly: AssemblyCompany("Danres")> <Assembly: AssemblyProduct("Codename: Dashboard Calculator")> <Assembly: AssemblyCopyright("")> <Assembly: AssemblyTrademark("")> <Assembly: AssemblyCulture("")> <Assembly: AssemblyVersion("1.1.518.942")> Namespace Danres.Dashboard Public Class Calculate Public Shared Function Calculate() As String Try Return ***CALCULATION*** Catch ex As Exception Return "Error" End Try End Function End Class End Namespace Now my app replaces ***CALCULATION*** with what the user wants to calculate and my application compiles the dll. Now my problem is how can i add a reference to the dll at runtime so i can call the Calculate Function or somehow call it without referencing? Thanks:) Dan Edited October 27, 2003 by dannyres Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.