摘要: //例1: procedure TForm1.Button1Click(Sender: TObject); var str: string; p: Pointer; begin p := @str; //变量 str 的地址 p := @Form1; //变量 Form1 的地址 p := @TForm1.Button1Click; //过程 TForm1.Butt... 阅读全文
posted @ 2007-11-26 23:27 万一 阅读(4983) 评论(2) 推荐(0) 编辑
摘要: procedure TForm1.Button1Click(Sender: TObject); var x: Integer; label n1,n2,n3,4; //goto的标签可以是标识符, 也可以是0..9999的数字 begin x := 0; goto n3; n1: x := x+1; n2: x := x+2; n3: x := x+3; 4: ... 阅读全文
posted @ 2007-11-26 22:55 万一 阅读(5426) 评论(6) 推荐(0) 编辑
摘要: //Byte procedure TForm1.Button1Click(Sender: TObject); var x,y: Byte; begin x := MAXBYTE; //MAXBYTE是常数255 y := not x; //y 的值是 0 x := 5; y := not x; //y 的值是 250 ShowMessage(IntToStr(y)... 阅读全文
posted @ 2007-11-26 22:40 万一 阅读(3492) 评论(10) 推荐(0) 编辑
摘要: 基本类型:数字Number,字符串String,布尔值Boolean; 复合类型:对象Object,数组Array; 工具类型:全局对象Global,日期Date,数学对象Math,正则表达式RegExp,错误对象Error; 特殊类型:函数Function。 阅读全文
posted @ 2007-11-26 13:17 万一 阅读(2376) 评论(4) 推荐(1) 编辑
摘要: 'BORLAND' { BORLAND } 'You''ll see' { You'll see } '''' { ' } '' { 空串 } ' ' { 空格 } #89#111#117 { You } #89'Y'#89 { YYY } #89 + 'Y' + #89 { YYY } #13#10 { 换行 } 阅读全文
posted @ 2007-11-26 11:58 万一 阅读(4586) 评论(2) 推荐(0) 编辑
摘要: //uses 子句一般这样写 uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; //这样写更清晰,因为Delphi忽略换行 uses Windows, Messages, SysUtils, Variants, Classes, Graph... 阅读全文
posted @ 2007-11-26 11:50 万一 阅读(6991) 评论(1) 推荐(0) 编辑
摘要: procedure DelFiles(f: string); var SearchRec: TSearchRec; begin ChDir(ExtractFilePath(f)); //进入文件路径 FindFirst(f, faAnyFile, SearchRec); repeat if FileExists(SearchRec.Name) then begi... 阅读全文
posted @ 2007-11-24 23:43 万一 阅读(3160) 评论(2) 推荐(0) 编辑
摘要: procedure TForm1.Memo1Click(Sender: TObject); begin Text := Format('当前列:%d, 当前行:%d', [Memo1.CaretPos.X, Memo1.CaretPos.Y]); end; //用 API 实现 procedure TForm1.Memo1Click(Sender: TObject); var Line... 阅读全文
posted @ 2007-11-24 23:04 万一 阅读(6785) 评论(11) 推荐(0) 编辑
摘要: //让 Edit 只接受数字 //方法1: procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not (Key in ['0'..'9']) then Key := Chr(0); end; //方法2: procedure TForm1.Edit1KeyPress(Sender: T... 阅读全文
posted @ 2007-11-24 11:48 万一 阅读(6351) 评论(20) 推荐(0) 编辑
摘要: //包含控件数: var num: Integer; begin num := Self.ControlCount; ShowMessage('窗体上共有控件: ' + IntToStr(num)); //没有包括不可视控件和panl内的控件 //ShowMessage('Panel1上共有控件: ' + IntToStr(Panel1.ControlCount)); end; ... 阅读全文
posted @ 2007-11-23 18:10 万一 阅读(3902) 评论(6) 推荐(0) 编辑