線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2134
推到 Plurk!
推到 Facebook!

access violation ?

答題得分者是:zycagod
crlin
一般會員


發表:47
回覆:57
積分:20
註冊:2002-07-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-09-26 10:20:15 IP:203.74.xxx.xxx 未訂閱
我的程式一開始有一個對話方塊要求輸入密碼, 叛斷密碼正確後才叫出主程式視窗, 但我輸入正確的密碼後卻出現以下訊息 Access violation at address 004705c3 in module 'PROJECT1.EXE', Read of address FFFFFFFF 按確定後仍可叫出主程式視窗且往後的程式也能正常執行 請問這是什麼原因呢 ? 我該如何消除這個錯誤訊息呢 ? thanks !
kan0515
中階會員


發表:56
回覆:120
積分:50
註冊:2002-06-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-09-26 11:29:31 IP:211.23.xxx.xxx 未訂閱
你的主程式可能是定義了某變數 而變數去存取值時無法取得 就會出現此種狀況 程式很大嗎? 放上來看看比較快
crlin
一般會員


發表:47
回覆:57
積分:20
註冊:2002-07-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-09-26 12:12:07 IP:203.74.xxx.xxx 未訂閱
以下是我的程式碼, 但我看不出有什麼變數會取不到值的啊 ? 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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-09-26 12:21:47 IP:203.74.xxx.xxx 未訂閱
以下是我的程式碼, 但我看不出有什麼變數會取不到值的啊 ? 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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-09-26 18:02:42 IP:211.23.xxx.xxx 未訂閱
那你的UNIT 1呢 也PO上來一下吧
crlin
一般會員


發表:47
回覆:57
積分:20
註冊:2002-07-23

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-10-02 09:58:26 IP:203.74.xxx.xxx 未訂閱
昨天重灌作業系統 同樣的地方仍有問題但多了一個除錯視窗 看不懂是什麼意思ㄝ ! 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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2002-10-02 10:04:29 IP:203.74.xxx.xxx 未訂閱
以下是我的 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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2002-10-02 14:56:53 IP:211.23.xxx.xxx 未訂閱
procedure TForm1.N44Click(Sender: TObject); begin AboutBox.Show; end; 會不會是這裡的問題呢??
crlin
一般會員


發表:47
回覆:57
積分:20
註冊:2002-07-23

發送簡訊給我
#9 引用回覆 回覆 發表時間:2002-10-02 15:19:05 IP:203.74.xxx.xxx 未訂閱
不是這個問題ㄝ , 我把 AboutBox.Show; 拿掉後, 問題仍存在 !
hagar
版主


發表:143
回覆:4056
積分:4445
註冊:2002-04-14

發送簡訊給我
#10 引用回覆 回覆 發表時間:2002-10-02 18:40:16 IP:211.22.xxx.xxx 未訂閱
建議您在輸入密碼這行設中斷點 然後用 F7 鍵來逐行 debug 找到出現 Access Violation 的那行程式碼會比較快。 -- Everything I say is a lie.
LYW
一般會員


發表:9
回覆:32
積分:8
註冊:2002-03-08

發送簡訊給我
#11 引用回覆 回覆 發表時間:2002-10-02 23:14:50 IP:61.225.xxx.xxx 未訂閱
crlin兄:
     請問您所有的Form都是自己Create的還是由Delphi內定Auto Create的?
crlin
一般會員


發表:47
回覆:57
積分:20
註冊:2002-07-23

發送簡訊給我
#12 引用回覆 回覆 發表時間:2002-10-03 08:33:10 IP:203.74.xxx.xxx 未訂閱
都是自己 create 的阿 !
zycagod
一般會員


發表:0
回覆:14
積分:12
註冊:2002-07-08

發送簡訊給我
#13 引用回覆 回覆 發表時間:2002-10-03 10:11:26 IP:61.220.xxx.xxx 未訂閱
引言: 都是自己 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還是開著吧
系統時間:2024-11-23 10:41:11
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!