如何将chart中的series的值保存(100分)

  • 主题发起人 主题发起人 auther
  • 开始时间 开始时间
A

auther

Unregistered / Unconfirmed
GUEST, unregistred user!
我想将chart中的series的值存成文本文件:
for k:=0 to iii-1 do
begin
b:=series1.YValue[k];
[red] a:=format('%8.2f',);[/red]
Writeln(DataFile,b);
end;
但是红色那句运行时有问题,错误是'Invalid floating point operation'
但是我看help,property YValue[Index:Longint]:Double
其返回值是double型的,为什么不能转换为字符传呢?
 
没有任知道怎么做么?
 
没有问题呀!
看看我的程序:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart, DbChart,
DB, DBTables;

type
TForm1 = class(TForm)
Table1: TTable;
DBChart1: TDBChart;
Series1: TLineSeries;
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
k,iii: Integer;
b: double;
a: string;
begin
iii := Table1.RecordCount;
memo1.Lines.Clear;
for k:=0 to iii-1 do
begin
b:=series1.YValue[k];
a:=format('%8.2f',);
memo1.Lines.Add(a)
end;
end;

end.

object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object DBChart1: TDBChart
Left = 0
Top = 0
Width = 329
Height = 273
BackWall.Brush.Color = clWhite
BackWall.Brush.Style = bsClear
Title.Text.Strings = (
'TDBChart')
TabOrder = 0
object Series1: TLineSeries
Marks.ArrowLength = 8
Marks.Visible = False
DataSource = Table1
SeriesColor = clRed
XLabelsSource = 'EmpNo'
Pointer.InflateMargins = True
Pointer.Style = psRectangle
Pointer.Visible = False
XValues.DateTime = False
XValues.Name = 'X'
XValues.Multiplier = 1
XValues.Order = loAscending
XValues.ValueSource = 'EmpNo'
YValues.DateTime = False
YValues.Name = 'Y'
YValues.Multiplier = 1
YValues.Order = loNone
YValues.ValueSource = 'Salary'
end
end
object Button1: TButton
Left = 32
Top = 288
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
object Memo1: TMemo
Left = 336
Top = 0
Width = 185
Height = 281
Lines.Strings = (
'Memo1')
ScrollBars = ssVertical
TabOrder = 2
end
object Table1: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'employee.db'
Left = 440
Top = 56
end
end

 
郁闷亚,今天什么都没有改,以运行就好了。谢谢another_benlei.
 
接受答案了.
 
后退
顶部