Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi 6 and equations

Status
Not open for further replies.

RZR

Programmer
Jun 19, 2006
2
LT
Hi, I have the problem, I am creating a mathematical program and I need to write equations. For example:
I write string 5+(3^3)/5 and program write equation like
MSWord equations. Maybe you know the component for delphi6 which can help me?

Sorry for mistakes :)
 
You have to remember the rules of 'Order of Operation'. They are -
[blue]
1. Calculations must be done from left to right.
2. Calculations in brackets (parenthesis) are done
first. When you have more than one set of brackets,
do the inner brackets first.
3. Exponents (or radicals) must be done next.
4. Multiply and divide in the order the operations
occur.
5. Add and subtract in the order the operations occur.
[/blue]

In other words, the way your example is written will be calculated in the following way -
1) 3^3 = 27
2) 27/5 = 5.4
3) 5 + 5.4 = 10.4

If you wanted to add the 5 before dividing by 5, then the equation needed to look like this -

( 5 + ( 3^3 ) ) / 5

It just a matter of grouping what you want calculated first with ().
 
As far as I am aware you should be able to use Word's Equation Editor directly (using OLE). I didn't bother to install it with Office because I have no need for it, so I can't test this. Look through your system's list of ActiveX controls or look in the Office folder for something like MSEQED70.OLB (name is just a guess but it will probably have an OLB extension) around which Delphi should be able to create a wrapper. (It may already be available on the VCL Servers tab)


Hope this helps.

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top