Need Some Help

Hello , i'm working on my project in c++Builder (i'm a beginner) and i have a problem.


I wanna do a program wich calculates math expresion.
Load from file bla bla (This are done)

The calculate Button looks like this ->


[code][b]String s,t,p;
int x;

s=Edit1->Text;

if(s.AnsiPos('+')!=0)
{
t=s.SubString(1,s.AnsiPos('+')-1);
p=s.SubString(s.AnsiPos('+')+1,s.Length());
x=StrToInt(t)+StrToInt(p);
Label1->Caption=IntToStr(x);
}
String a,b,c;
int y;

a=Edit1->Text;

if(a.AnsiPos('-')!=0)
{
b=a.SubString(1,a.AnsiPos('-')-1);
c=a.SubString(a.AnsiPos('-')+1,a.Length());
y=StrToInt(b)-StrToInt(c);
Label1->Caption=IntToStr(y); }[/b] [/code]

if I type 3+4 in the edit box , works
if I type 5-4 in the edit box , works
but if I type 4+5-5 it doesn't works .

If somebody knows , please give me a solution , or a Hint I'm a beginer and I wanna learn . THX (sorry for my english)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories