如何定义和使用一个返回boolean值得过程?
解决方案 »
- 初学delphi+sql 幸福+兴奋中……………………哈哈………………
- 颜色常量与字符串
- fastreport怎样竖直显示,且中间有一个空隔
- 如何实现:执行某操作出现一个提示框,显示正在载入?
- 谁错了?微软、宝兰还是我
- 关于数据集缓存更新的问题
- 如何查看系统当前的进程、如何终止(请写出原码)急
- 搬宿舍,绝对超低价格出售全新图书(附光盘)...
- 为什么在报表QrExpr的表达式里SUM(IF((Query1.YT='41'),3,(Query1.DYSL))),急
- 如何定义 怎么定义一个 自定义类型 的 常量? 一般 定义好的类型 的 定?义常量 有什么规律或者技巧
- 關於timer的interval問題
- 使用DBGrid的一点问题?
begin
result:= ;
end;
begin
CltDSet_Reader.Close;
with MCltDSetFunc do
begin
SetValue(CltDSet_Reader,'TableName', 'tb_Reader');
SetValue(CltDSet_Reader,'OptType', DataSelectWithTableName);
SetValue(CltDSet_Reader,'SelectWay', SelectExact);
SetValue(CltDSet_Reader,'SelectField', 'ReaderCord');
SetValue(CltDSet_Reader,'ReaderCord', Trim(Edt_ReaderCord.Text));
end;
try
CltDSet_Reader.Open;
if CltDSet_Reader.RecordCount >0 then
begin
result := true;
exit;
end;
except
showmessage('读者控制号查重出错!');
end;
result := false;
end;过程的话,就在过程内定义一个布尔值,在条件满足进就反回True,否则返回False;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function hello():Boolean;
public
{ Public declarations }
end;
function hell02():Boolean; //看清楚位置
var
Form1: TForm1;implementation{$R *.dfm}function TForm1.hello: Boolean;
begin
Result:=true;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
//使用
if hello() then
ShowMessage('hello');
if hello then
ShowMessage('hello');
end;function hell02():Boolean;
begin
Result:true;
end;end.
1、在使用以前声明,studentscxm(陈新明)给你的例子函数没有定义为TForm5的成员, 所以要先写了这段代码,才能其它后面实现的代码中使用;
2、这个例子并不是TForm5的成员成员,所以不写Form5.ReaderCord(...)而直接写成ReaderCord(...);
3、如果ReaderCord声明成TForm5的成员(Private或Public或其它段中声明),
那么在实现时一定要写成function TForm5.ReaderCord(pBarCode: string): boolean;
而这个函数的实现部分倒不必在引用它的程序代码段之前,因为已经在前面申明了的。