1、不带esle子句的if语句}ifTruethenWriteLn('This is simple if statement');{if ... then ... else if ... then ... esle if ... then ... else ...}//通过函数 Read 读取数字Read(nVar);ifnVar =1thenbeginWriteLn('status 1');endelseifnVar =2thenbeginWriteLn('status 2');endelseifn...
if CheckBox2.Checked then ShowMessage ('CheckBox2 is checked') else ShowMessage ('CheckBox2 is NOT checked'); 要注意的是,不能在第一句之后、else 关键词之前加分号,否则编译器将告知语法错误。实际上,if-then-else 语句是单纯的一条语句,因此不能在语句中间加分号。if 语句可以很复杂,句子中的条件部分...
DELPHI语法基础 注释 在Pascal中,注释括在大括号中或带星号的圆括号中。Delphi 也认可C++ 风格的注释,即把注释放在双斜线后。例如 {this is a comment} (* this is another comment *)// this is a comment up to the end of the line 第一种注释方式较简略,使用也较为普遍;第二种方式在欧洲使用较...
// compound if statement if CheckBox1.Checked then if CheckBox2.Checked then ShowMessage ('CheckBox1 and 2 are checked') else ShowMessage ('Only CheckBox1 is checked') else ShowMessage ( 'Checkbox1 is not checked, who cares for Checkbox2?') ...
ifsomestatementthenbegin...end;elsesomeotherstatementbegin...end; 1. 2. 3. 4. 5. 6. 7. 注意:end语句总是单独一行,当begin不为else语句的一部分时,相应的end语句与begin语句的缩进量相同 1.3.大小写规则 虽然Delphi中不区分大小写,但是采用统一的大小写规则也是极其有益的,能让大家在看代码时不至于不...
简单语句:单行:X:=Y+Z;调用一个过程Randomize;复合语句beginend;赋值:==表示关系运算符,用于判断是否相等用c:==条件if用and、or、not等布尔操作符联接起来的条件thenstatement;elsestatement;end;Case语句caseNumberof1:Text:='One';2:Text:='Two';else//default;Text:='Unknow';end;循环循环条件为顺序数...
if(判断语句) <执行语句1>; else <执行语句2>; (3)复合语句 delphi delphi的一个复合语句要用begin和end,开始一个复合语句要用begin,结束要用end; c语言 不用声明,直接使用,各种嵌套都不用. (4)delphi中的多分支语句 case语句 c a s e语句对一个结果的多个分支进行判断,具体形式如下: ...
will get the help of others. Life is like an echo, you send it back to what what, you reap what you sow, what you give is what you get. The if expression of then Begin A statement; End Else if two then expression Begin Statement two; ... End Else Begin N statement; End;...
// if-then-else statement if CheckBox2.Checked then ShowMessage ('CheckBox2 is checked') else ShowMessage ('CheckBox2 is NOT checked'); end; 注意的是,不能在第一句之后、else 关键词之前加分号,否则编译器将告知语法错误。实际上,if-then-else 语句是单纯的一条语句,因此不能在语句中间加分号 if ...
在某些情况下,使用 if-elseif-else 结构可能更具可读性,尽管 case 语句在处理多个离散值时更简洁。 示例 以下是一个简单的例子,演示了如何在 Delphi 中使用 case 语句: program CaseStatementExample; var number: Integer; begin number := 3; case number of 1: WriteLn('The number is one.'); 2: Wri...