delphi基础语法(1)

注释三种方法:

a、{ 注释 } b、 (* 注释 *) c、//注释

变量声明:

var i:integer; var X,Y:Real;

符号常量声明

const PI=1000; HH: integer=100;

声明文件和数组

F:File of TCurveData;

Data:array of TCurveData;

运算符

算术运算符:+,-,*,/,div,mod 其中,/是浮点除,结果为实数。div是整除,只能是整数。mod取模,只能是整数。

逻辑运算符

not,and,or,xor 其中,and逻辑与,or逻辑或,xor逻辑异或,not逻辑取反。返回值为true或false。

关系运算符

=,<>,<,>,<=,>= 判断不等使用<>,C语言中使用!=.

赋值运算符

i := i+1; Edit1.Text:='Hello'; //delphi中:=为赋值符号,=为判断是否相等。

条件语句

if语句

begin

if (i mod 39)=0 then

memo1.lines.add(inttostr(i));

end.

var x,y:integer;

begin

if x>0 then

y:=2*x;

else

y:=1-2*x;

writenln('y=',y);

end.

case语句

case i of

1:writeln('one');

2:writeln('two');

3:writeln('three');

else

writeln('other number');

end;

循环语句

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;

repeat和while..do循环

repeat

循环体;

until(循环条件;)

while (循环条件) do

begin

循环体;

end;

常用语句

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次方

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值