如何定义和使用一个返回boolean值得过程?
解决方案 »
- 为什么fsmainform与fschildform之间show总是内存地址出错?
- [讨论]进销存之OOP设计思路
- 超级菜鸟:speedbutton为何看不见?
- 怎样将查询到DBGrid1的Columns[0]进行排序。
- ERP系统的维护和服务费是怎么算的?
- 如何知道shelllistview中是否有东西被选中?????
- 再提TStringList.AddObject()方法的用法.
- UDP是不分SERVER和CLIENT的,那为什么还有IDUDPSERVER和IDUDPCLIENT??
- 如何用Indy组件完全模拟浏览器?
- 我是一菜鸟:请教DELPHEI中二维数组的定义
- 關於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;
而这个函数的实现部分倒不必在引用它的程序代码段之前,因为已经在前面申明了的。