第一个问题,看看下面代码有什么问题:
tbgs.First;
tbgz.Active:=true;
tbgz.First;
while not tbgs.Eof do
begin
while not tbgz.Eof do
begin
with query1 do
begin
close;
sql.Clear;
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='+tbgs.fieldbyname('公式右边').Value+'');
execsql;
end;
tbgz.Next;
end;
tbgs.Next;
end;
tbgz.Active:=false;为什么只能实现公式表中第一个公式的计算?第二个问题就是如何获得操作系统的系统目录比如win98是windows,2000却是winnt,如何在程序中获得是%systemdir%吗?呵呵,乱写一个
tbgs.First;
tbgz.Active:=true;
tbgz.First;
while not tbgs.Eof do
begin
while not tbgz.Eof do
begin
with query1 do
begin
close;
sql.Clear;
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='+tbgs.fieldbyname('公式右边').Value+'');
execsql;
end;
tbgz.Next;
end;
tbgs.Next;
end;
tbgz.Active:=false;为什么只能实现公式表中第一个公式的计算?第二个问题就是如何获得操作系统的系统目录比如win98是windows,2000却是winnt,如何在程序中获得是%systemdir%吗?呵呵,乱写一个
with query1 do
begin
close;
sql.Clear;
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='+tbgs.fieldbyname('公式右边').Value+'');
execsql;
end;
肯定会出问题,自己改变一下,try
2。search一下以前的帖子,很多
“tbgs.fieldbyname('公式左边').Value”的值返回的是字段名,
“tbgs.fieldbyname('公式右边').Value”的值作为赋值,
改为:
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='''+tbgs.fieldbyname('公式右边').Value+'''');试试
var
sysdir:array[0..255] of char;
begin
getwindowsdirectory(sysdir,255);
winexec(pchar(sysdir+'\calc.exe'),SW_SHOWNORMAL);end;
第二个
var
SystemDir : array[0..MAX_PATH] of Char;
begin
GetSystemDirectory(@SystemDir,MAX_PATH);
ShowMessage(SystemDir);
end;
tbgs.First;
while not tbgs.Eof do
begin
tbgz.Active:=true;
tbgz.First; //就是这个
while not tbgz.Eof do
begin
with query1 do
begin
close;
sql.Clear;
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='+tbgs.fieldbyname('公式右边').Value+'');
execsql;
end;
tbgz.Next;
end;
tbgs.Next;
end;
tbgz.Active:=false;2.GetSystemDirectory()
tbgz.Active:=true;
tbgz.First;
while not tbgs.Eof do
begin
tbgz.First;//加进去!!!!!
while not tbgz.Eof do
begin
with query1 do
begin
close;
sql.Clear;
sql.Add('update gzgl set '+tbgs.fieldbyname('公式左边').Value+'='+tbgs.fieldbyname('公式右边').Value+'');
execsql;
end;
tbgz.Next;
end;
tbgs.Next;
end;
tbgz.Active:=false;
另,调用计算器可以直接
shellexec('calc.exe');
或者winexec('calc.exe');