Jump to content
357mag

Does C++ Builder have a Clear() method?

Recommended Posts

I was doing my empty string things wrong. I used to think that "" and " " meant the same thing. I just learned they don't. To make an empty string you do "" with the quotation marks close together. Where as the " " means the space character which has an ASCII code of 32. 

Does C++ Builder have a Clear() method like C# does?

 

So if I didn't want to do this:

 

labelAnswer.Text = ""

 

I could use a Clear() method:

 

labelAnswer.Clear()

 

Something like that anyway.

Share this post


Link to post

I did not see anything about a Clear method so I guess I would have to use Edit1 -> Text = "".

Share this post


Link to post

There is EmptyStr constant, maybe it will help? I personally never bother of such things and always use '' / ""

Share this post


Link to post
Quote

Does C++ Builder have a Clear() method like C# does?

Some UI controls do, and some do not.

Quote

So if I didn't want to do this:

 

labelAnswer.Text = ""

 

I could use a Clear() method:

 

labelAnswer.Clear()

A TLabel control does not have a Clear() method, in either VCL or FMX.

 

Also, VCL's TLabel does not have a Text property, it has a Caption property instead:

labelAnswer->Caption = "";

On the other hand, FMX's TLabel does have a Text property.

On 4/16/2023 at 9:19 AM, 357mag said:

I did not see anything about a Clear method so I guess I would have to use Edit1 -> Text = "".

VCL's TEdit does have a Clear() method:

Edit1->Clear();

FMX's TEdit, on the other hand, does not.  However, it does have SelectAll() and DeleteSelection() methods instead:

Edit1->SelectAll();
Edit1->DeleteSelection();

 

Edited by Remy Lebeau

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×