在edit1.text中如何限制不让输入'这个字符?(50分)

H

harmer

Unregistered / Unconfirmed
GUEST, unregistred user!
在edit1限制不让输入A,可以这样写,但是如何限制不让输入'这个字符?
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if (Key in ['A', #8]) then Key := #0;
end;

if (Key in [''', #8]) then Key := #0; //这样写语法不对。
 
if (Key in ['''', #8]) then Key := #0;//中间的两个''既是你的"'"
 
'的ascii码是#39
 
zhoufujin和ifansee的有道理!
 
if key=#39 then key:=#0
 
ifcansee 说得对!!
找 '的ascii码
 
同意ifcansee
 
楼上有没有考虑到拷贝的情况阿,这样的话还是不行的哦,比较笨的办法是要遍历全部的text。
 
楼主只是说“如何限制不让输入'这个字符”,如果所以zhoufujin和ifcansee的回答是
正确的,不过单纯限制输入而不考虑COPY的情况确实不够完美,这就要看楼主的设计意
图了。



 
顶部