全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:715
推到 Plurk!
推到 Facebook!

用不到Tedit的屬性

答題得分者是:william
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-04-01 16:14:25 IP:203.185.xxx.xxx 未訂閱
我有個TForm,佢有個Tedit叫做username,另外我有個function叫checkvalid,個checkvalid係private function,但為什麼checkvalid係做唔到username.text呢?但係係其它form到就可以username.text?點解,唔係同一張form的就可以嗎?
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-04-01 16:28:18 IP:147.8.xxx.xxx 未訂閱
迷語< >< > Better post some of your code.. Or something like:
TForm1 = class (TForm)
    username: TEdit;
private
    function checkvalid: boolean;
end;
Or, is checkvalid a ordinal function not object method?
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-04-01 16:42:38 IP:203.185.xxx.xxx 未訂閱
unit Login; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TLoginForm = class(TForm) LoginNameLabel: TLabel; LoginNameEdit: TEdit; PasswordLabel: TLabel; PasswordEdit: TEdit; ConfirmButton: TBitBtn; CancelButton: TBitBtn; procedure ConfirmButtonClick(Sender: TObject); private { Private declarations } function DoLogin: Boolean; public { Public declarations } end; var LoginForm: TLoginForm; implementation {$R *.dfm} procedure TLoginForm.ConfirmButtonClick(Sender: TObject); begin if DoLogin = true then begin ModalResult := mrOk; end else begin ModalResult := mrNone; end; end; function TLoginForm.DoLogin() : Boolean; begin if StrLen(LoginNameEdit.text) = 0 then begin LoginNameEdit.SetFocus; Result := False; Exit; end; if StrLen(PasswordEdit.Text) = 0 then begin PasswordEdit.SetFocus; Result := False; Exit; end; end; end. ** 係dologin個到係call唔到LoginNameEdit.text Why?
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-04-01 16:49:41 IP:147.8.xxx.xxx 未訂閱
Your problem is StrLen... function StrLen(const Str: PChar): Cardinal; TEdit.Text is a string. Change StrLen to length.
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-04-01 17:04:21 IP:203.185.xxx.xxx 未訂閱
PChar?? Point of Char 同string有咩分別?係咪無'\n'分別?
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-04-01 17:10:11 IP:203.185.xxx.xxx 未訂閱
Application.MessageBox('abc' IntToStr(m_MaxLoginTimes) 'def', MB_OK); 不是pchar,那怎麼轉換?
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-04-01 17:18:37 IP:147.8.xxx.xxx 未訂閱
PChar is a pointer to a character (usually an array of characters) and often used as null terminated string. string default to huge (ansi) string, it is a dynamic string and there is no need for the null. Application.MessageBox(PChar('abc' IntToStr(m_MaxLoginTimes) 'def'), MB_OK);
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#8 引用回覆 回覆 發表時間:2004-04-01 17:40:37 IP:203.185.xxx.xxx 未訂閱
係c 個度,string係有'\n',咁即係有點唔同啦... 同麻想問多少少野,係咪所有class,如TForm, TButton or PChar()等等...佢括號裏的野pass左之後,return 都係個個相對class,如TForm, TButton or PChar...
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#9 引用回覆 回覆 發表時間:2004-04-02 11:34:35 IP:147.8.xxx.xxx 未訂閱
'\n' is linefeed in C , not necessary included in a string. C/C strings are null terminated while Delphi strings are not. TForm(xxx), PChar(xxx) are typecasting in Delphi.
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#10 引用回覆 回覆 發表時間:2004-04-02 11:47:18 IP:203.185.xxx.xxx 未訂閱
sorry,我打錯了,應該是'\n'-->'\0' ~"~;; 另外,c 好似都有個叫cstring/string的data type,那它也是有'\0'嗎? 謝謝你的解答,原來delphi有typecasting(同c 一樣),如TForm和TFormclass等等...
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#11 引用回覆 回覆 發表時間:2004-04-02 11:58:03 IP:147.8.xxx.xxx 未訂閱
cstring and string are classes in C .
BorlandUser
中階會員


發表:148
回覆:217
積分:73
註冊:2004-02-19

發送簡訊給我
#12 引用回覆 回覆 發表時間:2004-04-02 12:08:43 IP:203.185.xxx.xxx 未訂閱
原來如此,是我弄錯了,謝謝你的指教 ^_^
系統時間:2024-07-01 15:55:24
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!