var
a : integer;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsInteger;
Close;
end;
end;
12 个解决方案
#1
用REAL运算,再用FORMAT输出!
#2
主要是我不知道怎么写,请帮助!
#3
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
#4
这样显示还是好多位小数,我想将变量xy:=1236.369654中的数据直接显示在caption中,并使其保留2位小数。应该怎么做呢?
#5
我等着,请高手再看看
#6
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select Round(sum(a8),2) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select Round(sum(a8),2) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
#7
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
caption=Format('%8.2f',[a]);
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
caption=Format('%8.2f',[a]);
Close;
end;
end;
#8
同意楼上的兄弟!
#9
同意: rannado()
也可以考虑CONVERT或CAST
也可以考虑CONVERT或CAST
#10
Format('%8.2f',[a]);
#11
同意w8u(晌马)
如果不怕麻烦
可以用pos函数定位字符串中的小数点,然后用copy函数取子串
如果不怕麻烦
可以用pos函数定位字符串中的小数点,然后用copy函数取子串
#12
给分,感谢各位帮助!
#1
用REAL运算,再用FORMAT输出!
#2
主要是我不知道怎么写,请帮助!
#3
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
end;
#4
这样显示还是好多位小数,我想将变量xy:=1236.369654中的数据直接显示在caption中,并使其保留2位小数。应该怎么做呢?
#5
我等着,请高手再看看
#6
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select Round(sum(a8),2) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select Round(sum(a8),2) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
Close;
end;
#7
var
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
caption=Format('%8.2f',[a]);
Close;
end;
end;
a : double;
begin
with myQuery do
begin
close;
Sql.Clear;
Sql.Add('select sum(a8) as aaaa from table1 where...' );
Open
a := FieldByName('aaaa').AsFloat;
caption=Format('%8.2f',[a]);
Close;
end;
end;
#8
同意楼上的兄弟!
#9
同意: rannado()
也可以考虑CONVERT或CAST
也可以考虑CONVERT或CAST
#10
Format('%8.2f',[a]);
#11
同意w8u(晌马)
如果不怕麻烦
可以用pos函数定位字符串中的小数点,然后用copy函数取子串
如果不怕麻烦
可以用pos函数定位字符串中的小数点,然后用copy函数取子串
#12
给分,感谢各位帮助!