RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.UpCase Function

Converts a character to uppercase.

Pascal
function UpCase(Ch: AnsiChar): AnsiChar; overload;
function UpCase(Ch: WideChar): WideChar; overload;
C++
AnsiChar UpCase(AnsiChar Ch);
WideChar UpCase(WideChar Ch);

UpCase converts a character to uppercase. Ch is an expression of type Char. Character values not in the range a..z are unaffected.  

C++ Examples: 

 

/*
The following code uppercases every other character in the
text of an edit control when the user clicks the button.
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  // Get string from TEdit control
  UnicodeString s = Edit1->Text;
  for (int i = 1; i <= s.Length(); i += 2)
    s[i] = System::UpCase(s[i]);
  Edit1->Text = s;
}

 

Delphi Examples: 

{
The following code uppercases every other character in the
text of an edit control when the user clicks the button.
}
procedure TForm1.Button1Click(Sender: TObject);
var
  s : string;
  i : Integer;
begin
  { Get string from 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;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!