放了一个ADODataSet控件上去,我这么写怎么没有代码的自动提示?
迷惑....
unit login;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ADODB,main, DB;type
  TForm1 = class(TForm)
    txtUserName: TEdit;
    txtPassWord: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    dataset: TADODataSet;    //这里是TADODataSet
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;
implementation{$R *.dfm}function logins(p1:string;p2:string):boolean;   //准备写的是登陆判断函数.
begin
dataset.    //这里没有弹出提示,这么写不成吗?上边不是已经定义了dataset了吗?实在是迷惑...:(
result:=false;
end;procedure TForm1.Button2Click(Sender: TObject);  //关闭窗口
begin
close;
end;procedure TForm1.Button1Click(Sender: TObject);  //登陆按妞
begin
        if txtusername.Text='' then
        showmessage('输入用户名')
        else if txtpassword.Text='' then
        showmessage('输入密码')
        else  if logins(txtusername.Text,txtpassword.Text) then  //调用登陆函数进行判断
        begin
                form2.Show;
                form1.free;
        end
        else
        showmessage('no');
end;

解决方案 »

  1.   

    public
       function logins(p1:string;p2:string):boolean;
    function TForm1.logins(p1:string;p2:string):boolean;
    beginend;
      

  2.   

    楼上是正确的,你写的函数不是TForm1类的方法,所以不能直接访问类里的成员变量
      

  3.   

    type中private前加上function logins(p1:string;p2:string):boolean; 试试。
      

  4.   

    同意liangqingzhi(老之) 
      

  5.   

    liangqingzhi(老之) 正解. 你现在这样做,login函数不是FORM的成员.
      

  6.   

    加到了pubilc,但是
    procedure TForm1.Button1Click(Sender: TObject);
    begin
            if txtusername.Text='' then
            showmessage('输入用户名')
            else if txtpassword.Text='' then
            showmessage('输入密码')
            else if Tform1.logins(txtusername.Text,txtpassword.Text) then  //这里掉用出错
            begin
                    form2.Show;
                    form1.free;
            end
            else
            showmessage('no');end;
    调用出错,怎么回事,晕。
    错误提示:This form of method call only allowed for class methods
    这么写了也不能用呀。
      

  7.   

    Tform1.logins
    改为
    logins
    楼主对于类的概念不是很清晰。
      

  8.   

    对于类理论上我还是有些了解,但是放到DELPHI里就有些晕,楼上的师傅能讲讲吗?
    或者给我提供一些资料也可以,我对DELPHI的类的使用比较晕.谢谢您.
      

  9.   

    function Tform1(就这里了).logins(p1:string;p2:string):boolean;