数字转换为字符串
procedure TMainForm.InputChange(Sender: TObject);
var
I: Integer;
S, Number: string;
begin
Output.Text := '';
S := Input.Text;
if CheckBox.Checked then
begin
Number := '';
for I := 1 to Length(S) do
begin
if S[I] = '#' then
begin
if Number <> '' then
begin
Output.Text := Output.Text + Char(StrToInt(Number));
Number := '';
end;
end
else
begin
if S[I] in ['0'..'9'] then
Number := Number + S[I];
end;
end;
if Number <> '' then
Output.Text := Output.Text + Char(StrToInt(Number));
end
else
begin
for I := 1 to Length(s) do
begin
Output.Text := Output.Text + '#' + IntToStr(Ord(s[I]));
end;
end;
end;
var
I: Integer;
S, Number: string;
begin
Output.Text := '';
S := Input.Text;
if CheckBox.Checked then
begin
Number := '';
for I := 1 to Length(S) do
begin
if S[I] = '#' then
begin
if Number <> '' then
begin
Output.Text := Output.Text + Char(StrToInt(Number));
Number := '';
end;
end
else
begin
if S[I] in ['0'..'9'] then
Number := Number + S[I];
end;
end;
if Number <> '' then
Output.Text := Output.Text + Char(StrToInt(Number));
end
else
begin
for I := 1 to Length(s) do
begin
Output.Text := Output.Text + '#' + IntToStr(Ord(s[I]));
end;
end;
end;