?
Solved

Converting string to all upper case

Posted on 2003-03-27
6
Medium Priority
?
243 Views
Last Modified: 2010-04-04
I need to make sure that a user input is in all upper case for a form I am creating. How can I ether force the input as upper case or convert a string value into all upper case.


Thanks in advance

Mike
0
Comment
Question by:mfrost03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Accepted Solution

by:
pjenglund earned 200 total points
ID: 8219574
Try this function:

function UpperCase(const S: string): string;

Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit2.Text := Uppercase(Edit1.Text);
  {
   Edit2.Text will be the text in Edit1

end;
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8219576
Hi Mike.

Use UpperCase() to convert the string after the user input or use the OnKeyDown/Press event to force the user to input capital letters.

Markus
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8219597
TEdit also TDBEdit has a CharCase-Property

just set it to ecUpperCase

meikl ;-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:DaFox
ID: 8219613
Okay, if pjenglund already mentioned that I'll provide a way for my second suggestion. ;-)

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  // allow backspace and capital letters
  if not (Key in [#8, #65..#90]) then Key := #0;
end;

Markus
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8219657
> TEdit also TDBEdit has a CharCase-Property

Yep;

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key in [#97..#122]) then Key := Char(Ord(Key) - 32);
end;

Just kidding.
If you're using a TEdit set CharCase to UpperCase and that's it. I forgot about that, sorry...

Markus
0
 

Author Comment

by:mfrost03
ID: 8219945
Thanks! Both answers are correct, but this allows me to control when the test is in uppercase or when it is in Normal input.  

Just for Kicks I was also trying this to do a case update on each character in the string.

var

Cap: String;
i: Integer;

Begin
  cap1 := Edit1.Text;

  for i := 1 to Length(cap1) do
     cap1[i] := UpCase(cap1[i]);
  Edit1.Text := cap1;
End;

Thanks A Bunch!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question