function TFrm_main.MsgCounter(str: string): string; var s:string; //保存字符串 i,e,c:integer;//保存变量 begin s:=str; e:=0;c:=0; for i:=1 to length(s) do begin if (ord(s[i])>=33)and(ord(s[i])<=126) then //判断字符的顺序号 begin inc(e); end else if (ord(s[i])>=127) then //判断字符的顺序号 begin inc(c); end; end;