delphi中edit1,edit2,edit3,edit4,edit5,通过随机函数覆值后,怎么让五个edit中内容都不一样呢?请写出代码,多谢
解决方案 »
- 关于ADOdataset的批量跟新问题
- 求数据库程序设计方案
- 自定义联纸224×275 横向打印 总是出错,
- 为什么我的DELPHI7里边的WEB DEPLOY 和WEB DEPLOY OPTIONS为灰度不可操作的状态呢?
- 在线等待,会用TAdvStringGrid的高手请入
- 如何调用存储过程默认返回
- 请问怎么实现在DBGRID控件中显示的 文本内容自动换行?
- 实现XP风格的程序?
- Delphi 一般学到中级的水平要花多久?
- 有没有简单的移动文件的语句?
- 跪求indy http如何向服务器输入用户密码?一直在线等,直到解决,先谢了。
- 将XLS导入到到ACCESS后,如何再修改导入的字段名??请大家看看吧
begin
if (edit1.text=edit2.text) and () and() ....... then
随机函数();
else break;end;
a,b,c,d,e :string;
begin
Randomize;
edit1.Text:=IntToStr(random(21)+1);
edit2.Text:=inttostr(random(21)+1);
edit3.Text:=inttostr(random(21)+1);
edit4.Text:=inttostr(random(21)+1);
edit5.Text:=inttostr(random(21)+1);
a:=trim(edit1.Text);
b:=trim(edit2.Text);
c:=trim(edit3.Text);
d:=trim(edit4.Text);
e:=trim(edit5.Text);
while true do
if (a>b) or (a>c) or (a>d) or (a>e) or (b<a) or (b>c) or (b>d) or (b>e) or (c<a) or (c<b) or (c>d) or (c>e) or (d<a) or (d<b) or (d<c) or (d>e) or (e<a) or (e<b) or (e<c) or (e<d) then
edit1.Text:=inttostr(random(21)+1);
edit2.Text:=inttostr(random(21)+1);
edit3.Text:=inttostr(random(21)+1);
edit4.Text:=inttostr(random(21)+1);
edit5.Text:=inttostr(random(21)+1);
else break;//走到这一步就出现错误了,是怎么回事啊???????请高手指点!!!!
end;
begin
edit1.Text:=inttostr(random(21)+1);
edit2.Text:=inttostr(random(21)+1);
edit3.Text:=inttostr(random(21)+1);
edit4.Text:=inttostr(random(21)+1);
edit5.Text:=inttostr(random(21)+1);
end
else begin
...
end;
procedure TForm1.Button1Click(Sender: TObject);
var
I, J: Integer;
vEdit: TEdit;
begin
Randomize();
with TList.Create do try
for I := 1 to 21 do Add(Pointer(I)); // 得到全部1-21
for I := 1 to 5 do
begin
TComponent(vEdit) := FindComponent(Format('Edit%d', [I]));
if Assigned(vEdit) then
begin
J := Random(Count); // 随机抽取一个元素
vEdit.Text := Format('%d', [Integer(Items[J])]);
Delete(J); // 删除抽取的元素
end;
end;
finally
Free;
end;
end;