var p:PCharp:=PChar(str); While p^<>$0 do p^:=p^+3;
楼上的好像不行阿! 用什么uses阿!?
for I:= 0 to length(str) - 1 do begin str[I] := char(ord(str[I])+3); end;
procedure TForm1.Button1Click(Sender: TObject); var I: integer; str: string; begin str := 'ABC'; for I:= 0 to length(str) - 1 do begin str[I] := char(ord(str[I])+3); end; showmessage(str); end;
var S: string; I, N: Integer; begin S := '1234'; N := 3; // 要增加的数值 for I := 1 to Length(S) do S[I] := Chr(Ord(S[I]) + N); // char进行+3 Caption := S; end;
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } procedure AddChar(var AStr: string); public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.AddChar(var AStr: string); var i: Integer; begin for i := 1 to Length(AStr) do AStr[i] := Char((Ord(AStr[i]) + 3)); end;procedure TForm1.Button1Click(Sender: TObject); var vStr: string; begin vStr := 'ABC'; AddChar(vStr); ShowMessage(vStr); // DEF; end;end.
While p^<>$0 do
p^:=p^+3;
用什么uses阿!?
begin
str[I] := char(ord(str[I])+3);
end;
var I: integer;
str: string;
begin
str := 'ABC';
for I:= 0 to length(str) - 1 do
begin
str[I] := char(ord(str[I])+3);
end;
showmessage(str);
end;
S: string;
I, N: Integer;
begin
S := '1234';
N := 3; // 要增加的数值
for I := 1 to Length(S) do
S[I] := Chr(Ord(S[I]) + N); // char进行+3
Caption := S;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB, Grids, DBGrids;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure AddChar(var AStr: string);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.AddChar(var AStr: string);
var
i: Integer;
begin
for i := 1 to Length(AStr) do
AStr[i] := Char((Ord(AStr[i]) + 3));
end;procedure TForm1.Button1Click(Sender: TObject);
var
vStr: string;
begin
vStr := 'ABC';
AddChar(vStr);
ShowMessage(vStr); // DEF;
end;end.