delphi自定义函数添加 10

unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F... unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, ComCtrls, ExtCtrls, DBCtrls, Mask, DB,
ADODB;

type
TForm1 = class(TForm)
Panel1: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
GroupBox1: TGroupBox;
DBGrid1: TDBGrid;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBComboBox1: TDBComboBox;
Label3: TLabel;
DBComboBox2: TDBComboBox;
Label4: TLabel;
DBEdit2: TDBEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
GroupBox2: TGroupBox;
Label5: TLabel;
Edit1: TEdit;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DataSource3: TDataSource;
DataSource4: TDataSource;
ComboBox1: TComboBox;
Label6: TLabel;
ADOConnection1: TADOConnection;
ADODataSet2: TADODataSet;
Label7: TLabel;
ComboBox2: TComboBox;
ADODataSet3: TADODataSet;
procedure ComboBox1Change(Sender: TObject);
procedure ComboBox2Change(Sender: TObject);
procedure Button2Click(Sender: TObject);

private
{ Private declarations }

fuction GetIDByName(name:string;table:string):string;

public
{ Public declarations }

end;

var
Form1: TForm1;

implementation

{$R *.dfm}
{TForm1}
//根据名称得到编码函数
fuction TForm1.GetIDByName(name:string;table:string):string;
begin

ADODataSet2.Active:=false;
ADODataSet2.CommandText:='select id from'+table+'where name='''+name+'''';
ADODataSet2.Active:=true;
if not(ADODataSet2.IsEmpty)then
begin
GetIDByName:=ADODataSet2.FieldByName('id').AsString;
end
else
begin
Application.MessageBox('没有找到对应的编码!','错误',MB_OK);
end;
end;
我就想做一个根据名称得到编码的函数,本人初学者,请高手指点为什么会出现很多错误,哪错了捏?函数运行好了,我还要在调用它呢~谢了
展开
 我来答
hand114719
2009-03-31 · TA获得超过638个赞
知道小有建树答主
回答量:107
采纳率:0%
帮助的人:65.8万
展开全部
没有返回result,自然会出错

fuction TForm1.GetIDByName(name:string;table:string):string;
begin
..
..
//符合条件后
reult:=
//以上你没有返回结果,当然出错
end;
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式