在程序的public中声明了公用类,其中有7,8个string,现在想声明一个公用function,返回声明的公用类,我原以为要这样:
function GetDURG(InPUT:STRING):Class; 谁知道不对,请教该如何声明。
并且,该function中还有查询数据库的要求,
function GetDURG(InPUT:STRING):Class; 谁知道不对,请教该如何声明。
并且,该function中还有查询数据库的要求,
解决方案 »
- 我想要实现的是那种就像浏览文件夹那样,在根目录中建一个文件夹后会在执行后的treeview中显现出来,其文件夹中的txt或doc文件能够显现在richedit中
- 用ADO控件+SQL 编写的程序后果问题
- 柑桔MM进来接分!
- 初学IntraWeb,有一个小问题请教!
- 高手请进!!!!!!!!!!!!!!
- 哪位能把一个文件从一个指定的目录拷贝到一个指定的目录的源代码帖出来?在线等!
- 求高速公路收费系统软件:分数可以商量(我一共有3685分)!!!
- 求助好书
- 我用了updatasql后能修改,但怎样才能更新数据库?
- 计算机专业本科生的悲哀
- 如何在指定的字符串中查找双引号?在线
- 请问普通数据库应用程序可以转化为WEB方式吗~~!?
proceudre GetDURG(InPUT:STRING;var myclass:tmyclass);
在public 里没法添加控件,这个procedure是很多窗体都要用到的。
出错:
undeclared indetifier:'tadodataset';
unsaftisfied forward or externaldeclaration:"getDrugs"
在public里声明两共用类,其一纪录一些登陆信息(查询条件),临一个记录查询结果,在主窗体中获得登陆信息,在其他窗体中调用procedure or function, 查询数据库返回查询结果
这该如何写。
uses ....., ADODB;proceudre GetDURG(InPUT: string; myQuey: TAOQuery; var myclass: tmyclass);
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB;type
TMy = class
public
str1:string;
str2:string;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function getclass(adods:tadodataset):tmy;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function tform1.getclass(t:tadodataset):tmy;
begin
result.str1:='result';
result.str2:='result2';
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(getclass(nil).str1);
showmessage(getclass(nil).str2);
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ADODB;type
TMy = class
public
str1:string;
str2:string;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function getclass(adods:tadodataset):tmy;
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}function tform1.getclass(adods:tadodataset):tmy;
begin
result.str1:='result';
result.str2:='result2';
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(getclass(nil).str1);
showmessage(getclass(nil).str2);
end;end.
interface
uses
SysUtils,adodb;
type Drugs=class
InnerID:string;
DrugName:string;
AliasName:string;
InterID:string; DrugID:string;
CateID:string;
BigUnit:string;
PackUnit:string;
MinUNit:string;
MinQuan:double;
PackQuan:double;
InPrice:double;
WholePrice:double;
SellPrice:double;
PackPrice:double;
SelfRate:double;
AlerQuan1:double;
AlerQuan2:double;
CustID:string;
DrugInterID:string;
MedicareID:string;
MedicareClass1:string;
MedicareSelfRate1:double;
MedicareClass2:string;
MedicareSelfRate2:double;
MedicareClass3:string;
MedicareSelfRate3:double;
OkFlagName:boolean;
OkFlagSpecify:boolean;
end;
type Users=class
UserName:string;
PerID:string;
PerName:string;
WBorPY:string;
end;
var
S_Table,S_Field1,S_Field2:String;
I_Field1,I_Field2:String;
Flag:String;
EditFlag:String;implementationuses Us_StockMain, Us_DMHos;
end.
另:类不是这样写的,没有提供类成员的属性,外部没有访问这些成员的权限,你这样是record的写法。
For example, here is the declaration of the TMemoryStream class from the Classes unit.typeTMemoryStream = class(TCustomMemoryStream)
private
FCapacity: Longint;
procedure SetCapacity(NewCapacity: Longint);
protected
function Realloc(var NewCapacity: Longint): Pointer; virtual;
************************
property Capacity: Longint read FCapacity write SetCapacity;//属性Capacity,直接读取FCapacity,通过方法SetCapacity存储新值到FCapacity
************************
public
destructor Destroy; override;
procedure Clear;
procedure LoadFromStream(Stream: TStream); procedure LoadFromFile(const FileName: string);
procedure SetSize(NewSize: Longint); override;
function Write(const Buffer; Count: Longint): Longint; override;
end;
至于类,还是先看看关于面向对象方面的书吧。
我以前用vb做的类似的程序可以达到该功能,现在用delphi就不知道该增么写了。
虚心求教。
ado的嵌套查询没用过,把参数代入生成SQL语句就行了吧。
type
TUsers=record
UserName:string;
PerID:string;
PerName:string;
WBorPY:string;
end;...
...var
users:tusers;...
users.username:=....
...