你可以先单独调试randomize函数,看是不是每次Random都返回2
解决方案 »
- 我用IdTCPServer和IdTCpclient通讯的时候提示:Missing data provider or data packet
- 求一个储存过和的写法.
- 有关程序的监控的问题.
- 在DELPHI中调用.NET下写的WEBSERVICES问题??
- 哪里有quickreport3.51版下在?
- 如何将鼠标限定在窗体范围之内!
- 学习delphi的问题
- 急!如何隐藏程序进程?
- dbgird某行被选中,点击修改在另一个窗体得到该行的值
- csdn发行的程序员配套CD光盘特别版,CD上有什么东西,说能给我一个详细目录清单(我经常被内容丰富,大量实例等词汇搞晕了,买了,才。。。)
- 关于按钮的图片翻转问题,请指教,急急
- 如何使用代码实现主从表的连接?(急)
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount);(是不是要多几次用random,如用的话,如何用)
//i:=random(adotable1.RecordCount);
//while i>adotable1.RecordCount do
// i:=i-3;
adotable1.RecNo:=i;
adotable1.First;
adotable1.MoveBy(adotable1.RecNo); end;你两次运行程序取的值当然也是一样的了。因为种子一样。
如果你想不一样,可以用当前时间或其它可变的作为种子就可以了。如
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount);(是不是要多几次用random,如用的话,如何用)
//i:=random(adotable1.RecordCount);
//while i>adotable1.RecordCount do
// i:=i-3;
adotable1.RecNo:=i;
adotable1.First;
adotable1.MoveBy(adotable1.RecNo); end;你两次运行程序取的值当然也是一样的了。因为种子一样。
如果你想不一样,可以用当前时间或其它可变的作为种子就可以了。如
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount);(是不是要多几次用random,如用的话,如何用)
//i:=random(adotable1.RecordCount);
//while i>adotable1.RecordCount do
// i:=i-3;
adotable1.RecNo:=i;
adotable1.First;
adotable1.MoveBy(adotable1.RecNo); end;你两次运行程序取的值当然也是一样的了。因为种子一样。
如果你想不一样,可以用当前时间或其它可变的作为种子就可以了。如
帮你UP
-------------------------------------------
谢谢关注:http://expert.csdn.net/Expert/TopicView1.asp?id=845638
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount);(是不是要多几次用random,如用的话,如何用)
//i:=random(adotable1.RecordCount);
//while i>adotable1.RecordCount do
// i:=i-3;
adotable1.RecNo:=i;
adotable1.First;
adotable1.MoveBy(adotable1.RecNo); end;你两次运行程序取的值当然也是一样的了。因为种子一样。
如果你想不一样,可以用当前时间或其它可变的作为种子就可以了。如
Randomize;
adotable1.Open;
adotable1.First;
adotable1.RecNo := Random(adotable1.RecordCount);
Randomize;
adotable1.Open;
adotable1.First;
adotable1.RecNo := Random(adotable1.RecordCount);
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount);(是不是要多几次用random,如用的话,如何用)
adotable1.First;
adotable1.MoveBy(i);
end;
再执行adotable1.moveby(adotable1.recno),当然只向前移动1了。
这样用就行了。
i:=random(adotable1.RecordCount);
i:=random(adotable1.RecordCount);
i:=random(adotable1.RecordCount);
i:=random(adotable1.RecordCount);
再执行adotable1.moveby(adotable1.recno),当然只向前移动1了。
Randomize;
adotable1.Open;
adotable1.RecNo := Random(adotable1.RecordCount);
var
i,j:integer;
begin
i:=random(50000);
i:=random(50000);
i:=random(50000);
i:=random(50000);
j:=i mod adotable1.RecordCount;//j是最后取得的随机数。
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount-1);
adotable1.RecNo:=i+1;
end;
或
procedure TForm1.FormCreate(Sender: TObject);
var
i:integer;
begin
adotable1.Open;
randomize;
i:=random(adotable1.RecordCount-1);
//adotable1.RecNo:=i;
adotable1.First;
adotable1.MoveBy(i+1);
end;