Delphi备忘录——基本语句

选择语句:

1.If…Then…Else选择语句:

If (表达式) Then

Begin

语句块;

End

Else If(表达式) Then

Begin

语句块;

End;

Else

Begin

语句块;

End;

2.Case…Of…Else多分支控制语句:

Case (表达式) Of

情况常量值1:语句;

情况常量值2:语句;

情况常量值3:语句;

……

情况常量值n:语句;

Else: 语句;

End;

循环语句

1. While…do循环

While (表达式) do

语句

End;

2. Repeat…until循环(类似c中的do…while)

Repeat

语句

Until(表达式);

3. For…to…do循环(自变量增)

For 变量初值 to 终值 step 步长 do

Begin

语句块;

End;

4. For...downto…do循环(自变量减)

For 变量初值 downto 终值 step 步长 do

Begin

语句块;

End;

原文地址:https://www.cnblogs.com/bestlove/p/6607508.html