简单问题:数据类型转换的问题(50分)

N

nancyxi

Unregistered / Unconfirmed
GUEST, unregistred user!
有一个数据转换,由str转换成float时变成了1E-5,数据库中该字段定义为decimal(10,6)
数据无法存入数据表中,请问我如何才能避免这种情况的出现?
 
procedure TForm1.Button1Click(Sender: TObject);
var
f:real;
s:string;
begin
s:='0.000001';
showmessage(floattostr(strtofloat(s)));
showmessage(format('%10.6f',[strtofloat(s)]));
end;
 
to jxsjd
不用showmessage(Format()),该怎么办?
yvalue:=Format('%10.6f',[FloatTostr(RoundTo(Strtofloat(yvalue)/Abs(miny),-5))])
我是这么用的,编译不对
 
多看看书不就可以了吗?
 
看过format的帮助文件还是找不到办法呀,没人给回答一下吗?很急了。
 
yvalue:=Format('%10.6f',[Strtofloat(yvalue)/Abs(miny)])
 
to Another_eYes

yvalue:=FloatToStr(Format('%10.6f',[RoundTo(Strtofloat(yvalue)/Abs(miny),-5)]))
我是这么写的,编译说FloatToStr不能这么用??
 
你能看看清楚吗?
我的代码: yvalue:=Format('%10.6f',[Strtofloat(yvalue)/Abs(miny)])
你的代码: yvalue:=FloatToStr(Format('%10.6f',[RoundTo(Strtofloat(yvalue)/Abs(miny),-5)]))
 
多人接受答案了。
 
顶部