导航

const 最好少用

Posted on 2010-08-04 17:14  beeone  阅读(154)  评论(0编辑  收藏  举报
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ss : string;

implementation

{$R *.dfm}

procedure test1(const s: string);
begin
  try
    SS := '你好';
    ShowMessage(s);
  except
  on E:Exception do
  begin
    ShowMessage(E.Message);
  end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SS := 'Hello';
  Test1(ss);
end;

end.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ss : string;

implementation

{$R *.dfm}

procedure test1( s: string);
begin
  try
    SS := '你好';
    ShowMessage(s);
  except
  on E:Exception do
  begin
    ShowMessage(E.Message);
  end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SS := 'Hello';
  Test1(ss);
end;

end.

procedure test1(const s: string);
begin
  try
    SS := '你好';
    ShowMessage(Utf8ToAnsi(s));
  except
  on E:Exception do
  begin
    ShowMessage(E.Message);
  end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  SS := 'Hello';
  Test1(ss);
end;