//去掉字符串中的空格
function DelSpace(sStr:string):string;
var i:integer;
s1:string;
begin
s1:='';
for i:=1 to Length(sStr) do
begin
if copy(sStr,i,1)<>' ' then
s1:=s1+copy(sStr,i,1);
end;
result:=s1;
end;
同意henrynj,只做一点修改
function DelSpace(sStr:string):string;
var i:integer;
s1:string;
begin
s1:='';
for i:=1 to Length(sStr) do
begin
if sStr<>' ' then //只做这点修改
s1:=s1+sStr;
end;
result:=s1;
end;
同意楼上,只是加上一个删除全角空格的判断就更好了
function DelSpace(sStr:string):string;
var i:integer;
s1:string;
begin
s1:='';
for i:=1 to Length(sStr) do
begin
if (sStr<>' ') //判断半角空格
or (sStr<>' ') //判断全角空格
then
s1:=s1+sStr;
end;
result:=s1;
end;