delphi 中用:COPY(substring,string)SQL中用substring(substring,string)在onkeypress 事件中if not (key in ['0'..'9','.']) then showmessage('不能輸入字符');
1. s1:='123456789'; s2:=copy(s1,2,3); 也就是说:s2:='234' 2. if not (key in ['0'..'9','.'])
function copy(str:string;index,cnt:integer):string;in your OnKeyPress Event Handle: if not(key in ['0'..'9',',']) then ……
1:copy(s,starti,iend); 2:设置keypreview为True,然后再keypress事件里写代码: if key<>ord(',') and key<>ord(' ') Then ...........
function Copy(S; Index, Count: Integer): string;
if not (key in ['0'....'.']) then 后面该怎样写才能消掉那个非法字符?
function copy(str:string;index,cnt:integer):string;//取子串if not(key in ['0'..'9',',']) then//只能输入数字和’,‘ key=#0;
字符串的子串用copy函数,在delphi帮助文件中有详细的定义 此外还要定位,从什么地方开始,多少字符。定位可以用AnsiPos定位! 很简单第二个问题的话,如果只是希望输入数字和逗号可以用maskedit,也可以在onkeypress或者onkeydown的事件里进行判断用delphi的 in [..]很简单就能够实现!
借一方宝地再问一个问题。 if not(key in ['0'..'9',',']) then 之后连退格键也被屏蔽了,该怎么办呢?
if not(key in ['0'..'9',',',#8]) then showmessage('123'); 退格键 #8
s2:=copy(s1,2,3);
也就是说:s2:='234'
2. if not (key in ['0'..'9','.'])
if not(key in ['0'..'9',',']) then
……
2:设置keypreview为True,然后再keypress事件里写代码:
if key<>ord(',') and key<>ord(' ') Then
...........
后面该怎样写才能消掉那个非法字符?
key=#0;
此外还要定位,从什么地方开始,多少字符。定位可以用AnsiPos定位!
很简单第二个问题的话,如果只是希望输入数字和逗号可以用maskedit,也可以在onkeypress或者onkeydown的事件里进行判断用delphi的 in [..]很简单就能够实现!
if not(key in ['0'..'9',',']) then
之后连退格键也被屏蔽了,该怎么办呢?
showmessage('123');
退格键 #8
2:可以去判断按键的健值!想要输入的按键就把健值加进来,在响应的事件中判断