access violation ? |
答題得分者是:zycagod
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
|
kan0515
中階會員 發表:56 回覆:120 積分:50 註冊:2002-06-24 發送簡訊給我 |
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
以下是我的程式碼, 但我看不出有什麼變數會取不到值的啊 ? program Project1; uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit28 in 'Unit28.pas' {Form28},
{$R *.res} begin
Application.Initialize;
try
Application.Title := 'test';
//main form
Application.CreateForm(TForm28, Form28);
finally
end;
Application.Run;
end. /**************************/ unit Unit28; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables; type
TForm28 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Query1: TQuery;
Database1: TDatabase;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form28: TForm28;
user_name, password : String; implementation uses Unit1; {$R *.dfm} procedure TForm28.Button1Click(Sender: TObject);
var sqlCommand : String;
begin
user_name := Edit1.Text;
password := Edit2.Text;
sqlCommand := 'select count(*) as f1 from US_PS where user_name = ' char(39) user_name char(39);
Query1.SQL.Clear;
Query1.SQL.Add(sqlCommand);
Query1.Open;
if(Query1.FieldByName('f1').AsInteger = 0) then
begin
ShowMessage('查無此帳號 !');
end
else begin
sqlCommand := 'select password as f1 from US_PS where user_name = ' char(39) user_name char(39);
Query1.SQL.Clear;
Query1.SQL.Add(sqlCommand);
Query1.Open;
if(Query1.FieldByName('f1').AsString <> password) then
begin
ShowMessage('密碼錯誤 !');
end
else begin
self.Hide;
Form1:=TForm1.Create(Application);
Form1.Show;
end;
end;
end;
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
以下是我的程式碼, 但我看不出有什麼變數會取不到值的啊 ? program Project1; uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit28 in 'Unit28.pas' {Form28},
{$R *.res} begin
Application.Initialize;
try
Application.Title := 'test';
//main form
Application.CreateForm(TForm28, Form28);
finally
end;
Application.Run;
end. /**************************/ unit Unit28; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, DBTables; type
TForm28 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Query1: TQuery;
Database1: TDatabase;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Edit2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form28: TForm28;
user_name, password : String; implementation uses Unit1; {$R *.dfm} procedure TForm28.Button1Click(Sender: TObject);
var sqlCommand : String;
begin
user_name := Edit1.Text;
password := Edit2.Text;
sqlCommand := 'select count(*) as f1 from US_PS where user_name = ' char(39) user_name char(39);
Query1.SQL.Clear;
Query1.SQL.Add(sqlCommand);
Query1.Open;
if(Query1.FieldByName('f1').AsInteger = 0) then
begin
ShowMessage('查無此帳號 !');
end
else begin
sqlCommand := 'select password as f1 from US_PS where user_name = ' char(39) user_name char(39);
Query1.SQL.Clear;
Query1.SQL.Add(sqlCommand);
Query1.Open;
if(Query1.FieldByName('f1').AsString <> password) then
begin
ShowMessage('密碼錯誤 !');
end
else begin
self.Hide;
Form1:=TForm1.Create(Application);
Form1.Show;
end;
end;
end;
|
kan0515
中階會員 發表:56 回覆:120 積分:50 註冊:2002-06-24 發送簡訊給我 |
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
昨天重灌作業系統 同樣的地方仍有問題但多了一個除錯視窗
看不懂是什麼意思ㄝ ! procedure TCustomForm.SetVisible(Value: Boolean);
begin
if fsCreating in FFormState then
if Value then
Include(FFormState, fsVisible) else
Exclude(FFormState, fsVisible)
else
begin
if Value and (Visible <> Value) then SetWindowToMonitor;
inherited Visible := Value;
end;
end; 請問這代表什麼呢 ? thanks !
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
以下是我的 unit1 有點長 ! unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls,Unit28; type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
N24: TMenuItem;
N26: TMenuItem;
N27: TMenuItem;
N28: TMenuItem;
N29: TMenuItem;
N30: TMenuItem;
N33: TMenuItem;
N34: TMenuItem;
N35: TMenuItem;
N36: TMenuItem;
N37: TMenuItem;
N38: TMenuItem;
N39: TMenuItem;
N40: TMenuItem;
temp1: TMenuItem;
N41: TMenuItem;
N42: TMenuItem;
N43: TMenuItem;
N44: TMenuItem;
N45: TMenuItem;
N46: TMenuItem;
N47: TMenuItem;
N48: TMenuItem;
N20: TMenuItem;
N25: TMenuItem;
N49: TMenuItem;
procedure N5Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N37Click(Sender: TObject);
procedure N39Click(Sender: TObject);
procedure N30Click(Sender: TObject);
procedure N40Click(Sender: TObject);
procedure N28Click(Sender: TObject);
procedure N29Click(Sender: TObject);
procedure N43Click(Sender: TObject);
procedure N44Click(Sender: TObject);
procedure N45Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N46Click(Sender: TObject);
procedure N25Click(Sender: TObject);
procedure N41Click(Sender: TObject);
procedure N42Click(Sender: TObject);
procedure N47Click(Sender: TObject);
procedure N48Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure N15Click(Sender: TObject);
procedure N23Click(Sender: TObject);
procedure N26Click(Sender: TObject);
procedure N49Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation uses Unit3, Unit4, Unit2, Unit5, Unit6, Unit11, Unit9, Unit10, Unit7, Unit8,
Unit12, Unit13, Unit14, Unit16, Unit15, Unit18, Unit17, Unit19, Unit20,
Unit21, Unit22, Unit24, Unit25, Unit26, Unit27, Unit29, Unit30, Unit31,
Unit32; {$R *.dfm} procedure TForm1.N5Click(Sender: TObject);
begin
Form3:=TForm3.Create(Application);
Form3.Show;
end; procedure TForm1.N2Click(Sender: TObject);
begin
Form4:=TForm4.Create(Application);
Form4.Show;
end; procedure TForm1.N3Click(Sender: TObject);
begin
Form2:=TForm2.Create(Application);
Form2.Show;
end; procedure TForm1.N4Click(Sender: TObject);
begin
Form5:=TForm5.Create(Application);
Form5.Show;
end; procedure TForm1.N37Click(Sender: TObject);
begin
Form6:=TForm6.Create(Application);
Form6.Show;
end; procedure TForm1.N39Click(Sender: TObject);
begin
Form11:=TForm11.Create(Application);
Form11.Show;
end; procedure TForm1.N30Click(Sender: TObject);
begin
Form9:=TForm9.Create(Application);
Form9.Show;
end; procedure TForm1.N40Click(Sender: TObject);
begin
Form10:=TForm10.Create(Application);
Form10.Show;
end; procedure TForm1.N28Click(Sender: TObject);
begin
Form7:=TForm7.Create(Application);
Form7.Show;
end; procedure TForm1.N29Click(Sender: TObject);
begin
Form8:=TForm8.Create(Application);
Form8.Show;
end; procedure TForm1.N43Click(Sender: TObject);
begin
Form12:=TForm12.Create(Application);
Form12.Show;
end; procedure TForm1.N44Click(Sender: TObject);
begin
AboutBox.Show;
end; procedure TForm1.N45Click(Sender: TObject);
begin
Form14:=TForm14.Create(Application);
Form14.Show;
end; procedure TForm1.N20Click(Sender: TObject);
begin
Form24:=TForm24.Create(Application);
Form24.Show; end;
procedure TForm1.N21Click(Sender: TObject);
begin
Form15:=TForm15.Create(Application);
Form15.Show;
end; procedure TForm1.N46Click(Sender: TObject);
begin
Form18:=TForm18.Create(Application);
Form18.Show;
end; procedure TForm1.N25Click(Sender: TObject);
begin
Form26:=TForm26.Create(Application);
Form26.Show;
end; procedure TForm1.N41Click(Sender: TObject);
begin
Form19:=TForm19.Create(Application);
Form19.Show;
// Form24:=TForm24.Create(Application);
// Form24.Show; end; procedure TForm1.N42Click(Sender: TObject);
begin
Form20:=TForm20.Create(Application);
Form20.Show;
end; procedure TForm1.N47Click(Sender: TObject);
begin
Form22:=TForm22.Create(Application);
Form22.Show;
end; procedure TForm1.N48Click(Sender: TObject);
begin //Form21 shows how to print a text file
//Form21:=TForm21.Create(Application);
//Form21.Show;
Form25:=TForm25.Create(Application);
Form25.Show;
end; procedure TForm1.N22Click(Sender: TObject);
begin
Form27:=TForm27.Create(Application);
Form27.Show;
end; procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Visible := False;
Form28:=TForm28.Create(Application);
Form28.Show;
end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
Application.Terminate;
end; procedure TForm1.N15Click(Sender: TObject);
begin
Form29:=TForm29.Create(Application);
Form29.Show;
end; procedure TForm1.N23Click(Sender: TObject);
begin
Form30:=TForm30.Create(Application);
Form30.Show;
end; procedure TForm1.N26Click(Sender: TObject);
begin
Form31:=TForm31.Create(Application);
Form31.Show;
end; procedure TForm1.N49Click(Sender: TObject);
begin
Form32:=TForm32.Create(Application);
Form32.Show;
end;
end. 多謝 kan0515 兄的指教 !
|
kan0515
中階會員 發表:56 回覆:120 積分:50 註冊:2002-06-24 發送簡訊給我 |
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
LYW
一般會員 發表:9 回覆:32 積分:8 註冊:2002-03-08 發送簡訊給我 |
|
crlin
一般會員 發表:47 回覆:57 積分:20 註冊:2002-07-23 發送簡訊給我 |
|
zycagod
一般會員 發表:0 回覆:14 積分:12 註冊:2002-07-08 發送簡訊給我 |
引言: 都是自己 create 的阿 !procedure TForm1.FormCreate(Sender: TObject); begin Form1.Visible := False; ==>請改成 Self.Visible Form28:=TForm28.Create(Application); Form28.Show; end; procedure TForm28.Button1Click(Sender: TObject); self.Hide; Form1:=TForm1.Create(Application); Form1.Show; Emd; 這兩段加起來真的很奇怪....可以解釋這要幹嘛用的嗎?? 把Form28 hide 又進Form1.Create 把它Show出來? 而Form28不是已經Create了 何須在Create依次呢? 而且看起來到最後兩個Form還是開著吧 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |