⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 很好地delphi书籍源码
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TMyObject=class
   private
    Pri_Inf:string;
    { Private declarations }
   public
    Pub_Info:string;
    procedure SetPri_Inf(s:string);
    function  GetPri_Inf:string;
  end;

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  Ext_Info:string;

implementation
function TMyObject.GetPri_Inf: string;
begin
  GetPri_Inf:=Pri_Inf;
end;

procedure TMyObject.SetPri_Inf(s:string);
begin
  Pri_Inf:=s;
end;


{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Ext_Info:='向外部变量赋值成功!';
  Caption:=Ext_Info;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  with TMyObject.Create do
  begin
    Pub_Info:='向对象内部变量赋值成功!';
    Caption:=Pub_Info;
  end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  with TMyObject.Create do
  begin
    SetPri_Inf('通过接口向对象内部变量赋值成功!');
    Caption:=GetPri_Inf;
  end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -