我仍然是一个初学者,我一直在尝试自己解决这个问题,但我想我很走运。我认为这可能很简单,但是这很重要。
我有3个复选框。按下按钮但未选择任何按钮时,每一行都会在文本文件中写入一行。我希望显示一条消息。但是,即使选中了一个复选框,也会弹出消息。这是代码:(顺便说一句,随意建议任何其他使它更容易/更清晰的代码)
if cbSCV.Checked then
WriteLn(permFile, 'scv');
if cbMP.Checked then
WriteLn(permFile, 'mp');
if cbBTK.Checked then
WriteLn(permFile, 'btk');
if not (cbBTK.Checked) and not (cbMP.Checked) and not (cbBTK.Checked) then
showmessage('Choose at least 1 option.');
最佳答案
尝试将if sentence
替换为
if not (cbBTK.Checked) and not (cbMP.Checked) and not (cbSCV.Checked) then
因为您要两次检查
cbBTK.checked
值
关于delphi - 如果然后否则循环问题德尔福,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5944360/