Maths

dannyres

Regular
Joined
Aug 29, 2003
Messages
67
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
 
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.
 
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:

Visual Basic:
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
 
Last edited:
Back
Top