还有怎么让文本框不能只能输入数字和逗号?

解决方案 »

  1.   

    1、定位子串的起始位置(用pos函数)和长度(用Length函数),再用 copy 函数就可以得到子串。2、你的意思是要求只输入数字和逗号?   可以在 TEdit 的 OnKeyPress的时候判断 ord(key) 在 ord('0')到ord(9)和ord(',')的范围才接收就行了。
      

  2.   

    copy(s:string;index,const:integer):string;
      

  3.   

    delphi 中用:COPY(substring,string)SQL中用substring(substring,string)在onkeypress 事件中if not (key in ['0'..'9','.'])  then  showmessage('不能輸入字符');
      

  4.   

    1. s1:='123456789';
       s2:=copy(s1,2,3);
    也就是说:s2:='234'
    2. if not (key in ['0'..'9','.'])
      

  5.   

    function copy(str:string;index,cnt:integer):string;in your OnKeyPress Event Handle:
    if not(key in ['0'..'9',',']) then
      ……
      

  6.   

    1:copy(s,starti,iend);
    2:设置keypreview为True,然后再keypress事件里写代码:
    if key<>ord(',') and key<>ord(' ') Then
    ...........
      

  7.   

    function Copy(S; Index, Count: Integer): string;
      

  8.   

    if not (key in ['0'....'.']) then
    后面该怎样写才能消掉那个非法字符?
      

  9.   

    function copy(str:string;index,cnt:integer):string;//取子串if not(key in ['0'..'9',',']) then//只能输入数字和’,‘
     key=#0;
      

  10.   

    字符串的子串用copy函数,在delphi帮助文件中有详细的定义
    此外还要定位,从什么地方开始,多少字符。定位可以用AnsiPos定位!
    很简单第二个问题的话,如果只是希望输入数字和逗号可以用maskedit,也可以在onkeypress或者onkeydown的事件里进行判断用delphi的 in [..]很简单就能够实现!
      

  11.   

    借一方宝地再问一个问题。
    if not(key in ['0'..'9',',']) then
    之后连退格键也被屏蔽了,该怎么办呢?
      

  12.   

    if not(key in ['0'..'9',',',#8]) then
            showmessage('123');
    退格键 #8
      

  13.   

    1:function copy(str:string;index,cnt:integer):string;//取子串
    2:可以去判断按键的健值!想要输入的按键就把健值加进来,在响应的事件中判断