for counter := 1 to lengthofpassword do
begin
currentletter:=password[counter];
currentascii:=Ord(currentletter);
if (96<currentascii<123) OR (64<currentascii<91) OR (47<currentascii<58) then
Writeln('valid')
else
asciicheck:=false;
end;
我知道这段代码是错误的,但我做了解释我想问什么。如何指定if语句的范围?之前,我搞砸了很多if语句,并且我的代码没有按照我想要的方式工作。基本上,我正在制定一个程序,检查用户输入的大小写字母和数字以外的任何内容。这个问题是不同的,因为我正在寻找如何使用Case Of语句解决这个问题。如何在Delphi中为if语句指定多个范围?
for counter := 1 to lengthofpassword do
begin
currentletter:=password[counter];
currentascii:=Ord(currentletter);
if (currentascii<48) AND (currentascii>57) then
asciipoints:=asciipoints+1;
if (currentascii<65) AND (currentascii>90) then
asciipoints:=asciipoints+1;
if (currentascii<97) AND (currentascii>122) then
asciipoints:=asciipoints+1;
Writeln(asciipoints);
end;
我也试着像这样做,但后来意识到这是行不通的,因为如果一个声明是满意的,其他人也不会和计点积分制将不能工作。
什么是你的,当然目前的话题?你有什么需求来解决这个任务吗?否则,您可能需要查看一组char。 – nil
干杯,我结束了使用像97..122为字母表 –