swap交换两个
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure Swap_fun(var str_a:String; var str_b:String);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
str1: String;
str2: String;
temp: String;
begin
str1:= Edit1.Text;
str2:= Edit2.Text;
Swap_fun(str1, str2);
Edit1.Text:= str1;
Edit2.Text:= str2;
end;
procedure TForm1.Swap_fun(var str_a:String ; var str_b:String);
var
temp: String;
begin
temp:= str_a;
str_a:= str_b;
str_b:= temp;
end;
end.
wh1003665041 发表于 2013-8-8 16:54 static/image/common/back.gif
大哥 就是交换一下 用Delphi需要些这么多的代码吗??
他贴的是整个工程文件的代码,交换的核心代码也就是
temp:= str_a;
str_a:= str_b;
str_b:= temp; 表示内怎么看懂{:5_100:}
页:
[1]