关于Delphi里DBGrid组件内,如何产生一组随机时间的问题? 急急急,在线等!!!

按下打印按钮,想在交易日期那一列上按序随机产生20个2013-1-1到2013-12-31的随机日期,本人刚学delphi,请多多谅解,能中文注释下关键地方,下面有图有代... 按下打印按钮,想在交易日期那一列上按序随机产生20个2013-1-1到2013-12-31的随机日期,本人刚学delphi,请多多谅解,能中文注释下关键地方,下面有图有代码,谢谢!

procedure TForm1.dyClick(Sender: TObject);
begin
ClientDataSet1.FieldDefs.Clear;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rq';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'sj';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'je';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'ye';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'hh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'cdh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'rzh';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'qd';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'jym';
Size := 10;
DataType := ftString;
end;
with ClientDataSet1.FieldDefs.AddFieldDef do
begin
Name := 'zy';
Size := 10;
DataType := ftString;
end;
//动态创建数据集
ClientDataSet1.CreateDataSet;
//激活和打开该数据集
ClientDataSet1.Open;
ClientDataSet1.Append;
ClientDataSet1.FieldByName('rq').AsString:='20130904';
ClientDataSet1.FieldByName('sj').AsString:='094147';
ClientDataSet1.FieldByName('je').AsString:='-40000.00';
ClientDataSet1.FieldByName('ye').AsString:='114.30';
ClientDataSet1.FieldByName('hh').AsString:='19-2551';
ClientDataSet1.FieldByName('cdh').AsString:='2tu50012';
ClientDataSet1.FieldByName('rzh').AsString:='33765062';
ClientDataSet1.FieldByName('qd').AsString:='TERM';
ClientDataSet1.FieldByName('jym').AsString:='4213';
ClientDataSet1.FieldByName('zy').AsString:='现支';
ClientDataSet1.Post;
end;
展开
 我来答
dzx_deng
2014-09-19
知道答主
回答量:8
采纳率:0%
帮助的人:5万
展开全部
Randomize;
for i:=1 to 20 do
begin
edit2.Text:= formatdatetime('yyyymmdd',strtodate('2013/01/01')+(math.RandomRange(10,360)));
self.Memo1.Lines.Add(edit2.Text);
end;
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式