R
redwh
Unregistered / Unconfirmed
GUEST, unregistred user!
To jsxjd:
我这里已经解决了,你的办法不错,但是数据库计算的不够精确。现在将我的办法公布:
function TForm1.Calculate(Expression: string): string;
var
vScript: Variant;
begin
vScript := CreateOleObject('ScriptControl');
vScript.Language := 'JavaScript';
// vScript.Language := 'VBScript';
Result := vScript.Eval(Expression);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Calculate(edit1.Text));
end;
我这里已经解决了,你的办法不错,但是数据库计算的不够精确。现在将我的办法公布:
function TForm1.Calculate(Expression: string): string;
var
vScript: Variant;
begin
vScript := CreateOleObject('ScriptControl');
vScript.Language := 'JavaScript';
// vScript.Language := 'VBScript';
Result := vScript.Eval(Expression);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(Calculate(edit1.Text));
end;