All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
[delphi语法4]delphi中if语句的使用实例

Writer: aaa Article type: Programming skills(编程技巧) Time: 2014/7/19 0:14:09 Browse times: 484 Comment times: 0

[delphi语法4]delphi中if语句的使用实例


Head photo

Go homepage
Upload pictures
Write articles

[delphi语法4]delphi中if语句的使用实例|方法

If 语句
If 语句的结构如下:
if <条件> then
<语句>;
还可以为基本语句添加Else 子句:
if <条件> then
<语句>
else
<语句>;
需要注意的是,上面两个例子中的<语句>可以是单语句或复合语句。If...Then 语句被认为是单语句,在语句结束时只有一个分号(在第1 种情况的Then 引导的子句之后,或在第2 种情况的Else 引导的子句之后)。
例如下面的代码中Date 为整数类型,判断Date 如果在1 与10 之间显示为“上旬”、11 与20 之
间显示为“中旬”、21 与31 之间显示为“下旬”,如果数值不包含在上述范围内则显示“错误的日期”:
if (Date>=1) and (Date<=10) then
Writeln(’上旬’)
else if (Date>=11) and (Date<=20) then
Writeln(’中旬’)
else if (date>=21) and (Date<=31) then
Writeln(’下旬’)
else
Writeln(’错误的日期’);
注意:Else 子句之前,Then 引导的子句之后是不能有分号的。





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.