function GetSolidStr(const S: string): string;
var
Len: Byte;
FirstPos, LastPos: Byte;
begin
Result := '';
if S = '' then Exit; Len := Length(S);
FirstPos := 1;
while (FirstPos <= Len) and
(S[FirstPos] <= #32) do begin
Inc(FirstPos);
end;
if FirstPos > Len then Exit; for LastPos := Len downto FirstPos do begin
if S[FirstPos] > #32 then
Break;
end; Result := Copy ( S, FirstPos, LastPos - FirstPos +1 );
end;
var
Len: Byte;
FirstPos, LastPos: Byte;
begin
Result := '';
if S = '' then Exit; Len := Length(S);
FirstPos := 1;
while (FirstPos <= Len) and
(S[FirstPos] <= #32) do begin
Inc(FirstPos);
end;
if FirstPos > Len then Exit; for LastPos := Len downto FirstPos do begin
if S[FirstPos] > #32 then
Break;
end; Result := Copy ( S, FirstPos, LastPos - FirstPos +1 );
end;
EditBIRTHDATE.Text := GetSolidStr(EditBIRTHDATE.Text);
if (not(Length(EditBIRTHDATE.Text)in [8..10]) or ( Pos('-', EditBIRTHDATE.Text) <> 5 )) then
begin
Application.MessageBox('请您输入4位年号,年号、月份和日期用‘-’隔开。', '输入',MB_OK);
EditBIRTHDATE.SetFocus;
EditBIRTHDATE.SelectAll;
exit;
end
if (not(Length(EditBIRTHDATE.Text)in [8..10]) or ( Pos('-', EditBIRTHDATE.Text) <> 5 )) then
begin
//提示正确的输入格式
Application.MessageBox('请您输入4位年号,年号、月份和日期用‘-’隔开。', '输入',MB_OK);
//光标定位到EditBIRTHDATE文本框
EditBIRTHDATE.SetFocus;
//EditBIRTHDATE文本框中的所有文字被选中,应该呈蓝色
EditBIRTHDATE.SelectAll;
exit;
end
这个函数我也不太清楚,以前没有用过,我觉得这应该是你的程序里面的自己写的函数
据猜应该是去掉字符串中所有空格的函数,我去掉两边空格的时候一般用trim(引用sysUtils单元)
if S[FirstPos] > #32 then//错了吧 if S[LastPos ] > #32
Break;
end;取char(32) 中间的字符串;
for LastPos := Len downto FirstPos do begin
if S[FirstPos] > #32 then
应该是
for LastPos := Len downto FirstPos do begin
if S[LastPos] > #32 then另外, 这个函数可以简化一下:
function GetSolidStr(const S: string): string;
var
FirstPos, LastPos: Integer;
begin
Result := '';
if S = '' then exit;
for FirstPos := 1 to Length(S) do
if S[FirstPos] > #32 then
begin
for LastPos := Length(S) downto FirstPos do
if S[LastPos] > #32 then
begin
Result := Copy(S, FirstPos, LastPos - FirstPos + 1);
break;
end;
break;
end;
end;
找一下asicc码表,要不我找一下?