如何專案中2個form傳遞變數 |
答題得分者是:mi86018
|
Komuro
一般會員 發表:27 回覆:46 積分:14 註冊:2004-02-19 發送簡訊給我 |
|
mi86018
一般會員 發表:20 回覆:39 積分:21 註冊:2003-11-17 發送簡訊給我 |
假設:form2 有一個變數temp,要讓form1的buttom1按下後,form1的edit1顯示temp的值。 form2程式碼:
unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm2 = class(TForm) procedure FormCreate(Sender: TObject); private { Private declarations } public temp:String; { Public declarations } end; var Form2: TForm2; implementation {$R *.dfm} procedure TForm2.FormCreate(Sender: TObject); begin temp := 'abcd'; end; end.------------------------- form1程式碼: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text := form2.temp; end; end.我是頭號「問題」份子... |
Komuro
一般會員 發表:27 回覆:46 積分:14 註冊:2004-02-19 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |