UpCase (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code changes the capitalization of every other character in the text of an edit control to uppercase when you click the button.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  s : string;
  i : Integer;
begin
  { Get string from the TEdit control. }
  s := Edit1.Text;
  for i := 1 to Length(s) do
    if i mod 2 = 0 then s[i] := System.UpCase(s[i]);
  Edit1.Text := s;
end;

Uses