delphi 总结

本文总结了Delphi编程的多个关键概念,包括单元文件结构、程序文件组成、注释方式、常用函数、参数传递方式、数据控制组件的使用、数据库连接与查询以及异常处理。还介绍了组件如RadioButton、PopupMenu的使用,以及动态创建Form和调用Windows API函数。此外,还涵盖了文件操作、数据集操作、属性类型和子程序的区别。
摘要由CSDN通过智能技术生成

1.单元文件  p11

(1)单元头 unit xxx

(2)接口部分:从interface开始,到implementation之前结束。有uses、type、var等语句。

(3)实现部分:以implementation开始。

(4)初始化部分:以initialization开始。

(5)结束部分:以finalization开始。

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

end;

end.


2.程序文件

(1)程序首部:program xxx;

(2)说明部分:有uses、type、var等语句。

(3)执行部分:begin开始,end结束。

program Project1;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


3.注释方式 p15

(1)单行注释: //

(2)多行注释:{   }  或者(*      *)


4. 常用标准函数

sqr(x) 平方

sqrt(y) 开根号

int(x) 取整

ord('A') 求ascii码

inc(x) inc(x,3) 自增

dec(x)  自减

odd(x) 奇函数

pred(x) x-1

succ(x) x+1

chr(x) 返回ascii值


5.静态数组

var   
 d:array [1..10] of integer; //一维数组
 e:array [1..3,1..5] of integer;  //二维数组

 

动态分配数组

var
    c:array of integer;
begin
  setlength(c,10);
  writeln(c[0]);
  readln;
end.


6. if语句

if a=b then
          writeln(1)
       else if a>b then
          writeln(2)
       else writeln(3);


7.  for语句


a:=0;
  for i:= 1 to 10 do
  begin
    inc(a);
    writeln(a);
  end;
  readln;


8. while语句

i:=0;
  while i<10 do
  begin
    writeln(i);
    inc(i);
  end;

9. 过程 procedure

procedure p1(a:integer);
begin
writeln(a);
end;

10.函数 function。 比procedure多一个返回值

function myinc(a:integer):integer;
begin
  result:=a+1;
end;


11.调用参数传递方式

(1)值参数(形式参数):procedure f(a:integer);

(2)变量参数(传地址):procedure f(var a:integer);

(3)常参数:                     procedure f(const a:integer);


12. 定义记录 record。记录不能定义过程和函数,只是类型的集合。


                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值