在memo输入时候,如何把全角','转成半角','   我看到onkeypress中输入中文字符会执行两次onkeypress 
哪位作过这?

解决方案 »

  1.   

    Memo不支持UniCode,建议使用TNT控件的Memo就可以达你的要求.
    当然,还有一个笨办法
    procedure TForm1.Memo1Exit(Sender: TObject);
    begin
      Memo1.Text:=AnsiReplacestr(Memo1.Text,',',',');
    end;
      

  2.   

    procedure TForm1.Memo1Change(Sender: TObject);
    begin
      memo1.Text:=AnsiReplacestr(memo1.Text,',',',');
      memo1.SelStart:= length(memo1.Text);
    end;
      

  3.   

    VCL组件不支持unicode的,可以用楼上的替换方法,也可以自己写函数完成
      

  4.   

    现在程序的要求是
      要求能输入1~9, '-' , ',' 回车,backspace
    我在keypress中写了
      if not ((Key In ['0'..'9',chr(8),#13,',','-']) or (Key in [#8,#3,#22,#24])) then  begin key:=#0; exit; end;   希望能同时具有这些功能 ?谁能指导一下? tnt控件是有 不熟悉啊 给个简单例子吧?
      

  5.   

    现在程序的要求是
      要求能输入1~9, '-' , ',' 回车,backspace
    我在keypress中写了
      if not ((Key In ['0'..'9',chr(8),#13,',','-']) or (Key in [#8,#3,#22,#24])) then  begin key:=#0; exit; end;   希望能同时具有这些功能 ?谁能指导一下? tnt控件是有 不熟悉啊 给个简单例子吧?或者在onkeypress中的   key的值是多少=‘,’也行
      

  6.   


    可以输入数字,退格,回车,以及,
    procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    begin
      if  not (key  in ['0'..'9']) and (key <> #8) and (key <> #13) and (key <> ',')  then
       key := #0;
    end;
      

  7.   

    可以输入数字,退格,回车,以及,和,procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    begin
      if  not (key  in ['0'..'9']) and (key <> #8) and (key <> #13) and (key <> ',') and (key <> #163)  then
       key := #0;
    end;
      

  8.   

    tnt控件不熟悉啊 给个简单例子吧?或者在onkeypress中怎么处理一下?
      

  9.   

    最关键的是要把全角的',',转成半角'  同时又能输入数字回车,backspace等等
      

  10.   

    procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
    begin
      if key= #163 then key := ',';
      if  not (key  in ['0'..'9']) and (key <> #8) and (key <> #13) and (key <> ',')   then
       key := #0;
    end;
      

  11.   

    如果你发现上面的例子不能用,就在onkeypress中跟踪一下,看看当你按下全角的,时  key的值是多少,然后把上面例子中的#163改成那个值就可以了。
      

  12.   

    to wudi_1982 : 佩服你的水平