有一段通过检查checkbox来提醒用户设置查询条件的程序老是错,请指点。(50分)

C

ccll

Unregistered / Unconfirmed
GUEST, unregistred user!
function funckeckoneleast(sender: TForm): boolean;
var
i:integer;
begin
result:=false;
for i:=0 to Sender.ComponentCount-1 do
begin
if Sender.Components is TCheckBox then
begin
if (sender.Components as TCheckBox).checked then
begin
result:=true ;
break;
end;
end;
end;
if (result=false) and (MessageDlg('不设置可能会占用很多时间,继续吗?',mtConfirmation, [mbYes,mbNo],0)=mrYes) then
result:=true;
end;
 
什么意思,一旦有选择的马上退出,返回真值
一旦没有真值,提示,这样有什么用,不知具体是哪 一个
 
BREAK是从FOR循环退出。
并不是退出过程,所以无论如何你的最后一句都绘执行,就达不到
你的目的。
把BREAK 改成EXIT;

把这句话删除:
if (result=false) and (MessageDlg('不设置可能会占用很多时间,继续吗?',mtConfirmation, [mbYes,mbNo],0)=mrYes) then
result:=true;
改成其他地方外部调用这个函数:
if funckeckoneleast(sender: TForm) and (MessageDlg('不设置可能会占用很多时间,继续吗?',mtConfirmation, [mbYes,mbNo],0)=mrYes) then
result:=true;
 
請問有什么錯,在我這運行很好。
 

if (result=false) and (MessageDlg('不设置可能会占用很多时间,继续吗?',mtConfirmation, [mbYes,mbNo],0)=mrYes) then
result:=true;
改为:
if result= false then
if MessageDlg('不设置可能会占用很多时间,继续吗?',mtConfirmation, [mbYes,mbNo],0)=mrYes then
reslut := true;
不就可以了吗?
 
顶部