我目前有一个记录(具有不同的值)和三个具有特定指定值的用户常量(例如名称等).
我可以将编辑框与一个用户进行比较,如下所示:
if edit1.text = user1
then xxxx
Run Code Online (Sandbox Code Playgroud)
这一切都很好,但是如何指定编辑框必须在三个不同的用户之间进行检查?
例:
if edit1.text = user1 to user3
then xxxx
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
最新版本的Delphi(我使用XE)包含单元StrUtils.pas
function MatchText(const AText: string; const AValues: array of string): Boolean;
function MatchStr(const AText: string; const AValues: array of string): Boolean;
Run Code Online (Sandbox Code Playgroud)
MatchStr是区分大小写的版本.
您的问题现在可以像这样解决:
if MatchStr(edit1.text, [user1, user2, user3])
then xxxx
Run Code Online (Sandbox Code Playgroud)