Inno Setup使用多个验证表达式禁用“下一步"按钮(当输入值与多个值之一匹配时) [英] Inno Setup Disable Next button using multiple validation expressions (when input value matches one of multiple values)

查看:90
本文介绍了Inno Setup使用多个验证表达式禁用“下一步"按钮(当输入值与多个值之一匹配时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码在起作用...

I have this code working ...

procedure ValidatePage;
begin 
  WizardForm.NextButton.Enabled :=
    (CompareText(InputPage6.Values[EditIndex2], 'Admin') <> 0);
end;

procedure EditChange(Sender: TObject);
begin
  ValidatePage;
end;

procedure PageActivate(Sender: TWizardPage);
begin
  ValidatePage;
end;

但是我想添加更多验证.

But I want to add more validations.

示例:如果不允许使用 EX12345 EX54321 .

Example: If you have not allowed EX12345 or EX54321.

WizardForm.NextButton.Enabled :=
  (CompareText(InputPage6.Values[EditIndex2], 'EX12345') <> 0);

WizardForm.NextButton.Enabled :=
  (CompareText(InputPage6.Values[EditIndex2], 'EX54321') <> 0);

推荐答案

如果我对您的理解正确,那么您在问如何将多个逻辑表达式组合为一个.使用布尔运算符,尤其是运算符

If I understand you correctly, you are asking how to combine multiple logical expressions into one. Use boolean operators, particularly and operator.

procedure ValidatePage;
begin 
  WizardForm.NextButton.Enabled :=
    (CompareText(InputPage6.Values[EditIndex2], 'EX12345') <> 0) and
    (CompareText(InputPage6.Values[EditIndex2], 'EX54321') <> 0);
end;

特别是如果您要添加更多选项,则可以通过将值首先存储到局部变量中来优化代码:

Particularly if you are going to add even more options, you can optimize the code by storing the value into a local variable first:

procedure ValidatePage;
var
  Value: string;
begin 
  Value := InputPage6.Values[EditIndex2];

  WizardForm.NextButton.Enabled :=
    (CompareText(Value, 'EX12345') <> 0) and
    (CompareText(Value, 'EX54321') <> 0);
end;

这篇关于Inno Setup使用多个验证表达式禁用“下一步"按钮(当输入值与多个值之一匹配时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆