Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted
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.
Posted (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 by dannyres

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...