有關aphla 問題 |
尚未結案
|
Dark852
一般會員 ![]() ![]() 發表:14 回覆:19 積分:6 註冊:2004-09-25 發送簡訊給我 |
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
1) I think you need to write your own function, not difficult. Or you want to take a look at API IsCharAlpha? 2) Use function ord to get the ASCII code of a character. http://pywong.hk.st http://www.lazybones.ca
|
Dark852
一般會員 ![]() ![]() 發表:14 回覆:19 積分:6 註冊:2004-09-25 發送簡訊給我 |
請問我以下的Coding有什麼問題呢為什麼Run不到呢
我是想驗証TEdit 的 Text Value 是不是 Alpha 之後Return T or F function TFEdit.CheckAlpha: Boolean;
var checkText: string;
tmp:integer;
i: integer;
begin
Result:= False;
checkText:= self.Text; For i:=1 To length(self.Text) Do
Begin
tmp:=Ord(Copy(self.Text,i,1)); <----incompatible types
if Not(65>=tmp and tmp<90) then <----incompatible types
Exit;
End;
Result:= True;
end;
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
function TFEdit.CheckAlpha: Boolean; var checkText: string; tmp:integer; i: integer; begin Result:= False; checkText:= self.Text; For i:=1 To length(self.Text) Do Begin tmp:=Ord(Text[i]); if Not((65>=tmp) and (tmp<90)) then Exit; End; Result:= True; end;http://pywong.hk.st http://www.lazybones.ca |
Dark852
一般會員 ![]() ![]() 發表:14 回覆:19 積分:6 註冊:2004-09-25 發送簡訊給我 |
William 大大 我有一個問題耶 function TFEdit.CheckAlpha: Boolean;
var checkText: string;
tmp:integer;
i: integer;
begin
Result:= False;
checkText:= self.Text; For i:=1 To length(self.Text) Do
Begin
tmp:=Ord(Text[i]);
if Not((65>=tmp) and (tmp<90)) then
Exit;
End;
Result:= True;
end; 為什麼我輸入的是一個 'A' 他還會Retrun False 呢 是不是我的 coding 有問題
|
william
版主 ![]() ![]() ![]() ![]() ![]() 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
It works, perhaps you could use checkText instead of Text? BTW, you didn't check the case... so as an example:
function CheckAlpha(const Text: string): Boolean; var i: integer; begin Result:= True; i := 1; while Result and (i<=length(Text)) do begin Result := (Text[i] in ['a'..'z','A'..'Z']); inc(i); end; end;Of course you can use ord if you want, but I am lazy |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |