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

相关阅读 >>

Delphi 删除字符串中指定字符

Delphi listview中加载图片

Delphi 让combobox只允许输入数字和回车键以及Delphi key值表

Delphi sendmessage postmessage 原理和区别

Delphi adoconnection1连接mssql数据库方法

Delphi 访问https图片

Delphi 根据ip获取局域网mac

Delphi 截屏函数(包含截取鼠标形状)

Delphi 将listview保存为txt

Delphi xe2-firemonkey 新功能

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...