delphi入门语法  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi入门语法


注释:
代码  //注释
代码  {   注释   }
代码  *   注释   *
1
2
3
变量声明:
var i:integer;
var X,Y:Real;
1
2
符号常量声明
const 
   PI=1000;
   HH: integer=100;
1
2
3
声明文件和数组
F:File of TCurveData;
Data:array of TCurveData;
1
2
运算符
算术运算符:
+,-,*,/,div,mod    
 //其中,/是浮点除,结果为实数。div是整除,只能是整数。mod取模,只能是整数。
1
2
逻辑运算符
not,and,or,xor         
//其中,and逻辑与,or逻辑或,xor逻辑异或,not逻辑取反。返回值为true或false。
1
2
关系运算符
=,<>,<,>,<=,>=         
//判断不等使用<>,C语言中使用!=.
1
2
赋值运算符
i := i+1;  
Edit1.Text:='Hello';   
//delphi中:=为赋值符号,=为判断是否相等。
1
2
3
条件语句
1:if语句

begin
if (i mod 39)=0 then
memo1.lines.add(inttostr(i));
end.
1
2
3
4
var x,y:integer;
begin
if x>0 then
   y:=2*x;
   else 
   y:=1-2*x;
   writenln('y=',y);
   end.
1
2
3
4
5
6
7
8
2:case语句

  case i of 
     1:writeln('one');
     2:writeln('two');
     3:writeln('three');
    else 
      writeln('other number');
  end;
1
2
3
4
5
6
7
循环语句
1:for循环

begin
   DT:=0.01;
   for I:=-500To 500 do
   begin
   X:=DT*I;
   Y:=10*cos(4*X);
   Chtcurve.series[0].AddXY(X,Y);
end;
1
2
3
4
5
6
7
8
2:repeat和while..do循环

repeat
   循环体;
until(循环条件;)

while (循环条件) do
 begin
   循环体;
 end;
1
2
3
4
5
6
7
8
常用语句
1:Memo2.lines.add(floattostr(K));     
//将实型K值转换为字符型,再添加到memo2中。
2:x:=strtoint(edit1.text);     
//将edit1中的字符串转换为整形赋值给变量x。
3:delphi时间提取:label5.Caption:=datetimetostr(now);  
//timer组件
   时间停止:timer1.enabled:=false;
   时间开始:timer1.Enabled :=true;
4:power(x,n)  指x的n次方
————————————————

原文链接:https://blog.csdn.net/AlexMYH/article/details/80330649

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.031949043273926 seconds