| |

VerySource

 Forgot password?
 Register
Search
View: 1155|Reply: 2

A primary question of Delete in Delphi!

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-12-16 12:00:02
| Show all posts |Read mode
I just started to learn DELPHI, and I don’t understand many questions, and I can’t solve them after all. Ask the big brothers and sisters? Ha...

I dragged several controls in Delphi. Then, in a BUTTON click event, I wrote the following:
  Begin
        Label1.Caption:=Concat(Edit1.text,Edit2.text);
        Label2.Caption:=Delete(Label1.Caption,1,1);
  End;
Celsius, prompt:
[Error] Unit1.pas(34): Constant object cannot be passed as var parameter
I then changed it to:
var
        S:string;
begin
        Label1.Caption:=Concat(Edit1.text,Edit2.text);
        S:=label1.Caption;
        Label2.Caption:=Delete(S,1,1);
end;
The result is:
[Error] Unit1.pas(35): Incompatible types:'String' and'procedure, untyped pointer or untyped parameter'

Dare to ask everyone, what does this mean?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-20 06:00:01
| Show all posts
Changed to:
var
        S:string;
begin
        Label1.Caption:=Concat(Edit1.text,Edit2.text);
        S:=label1.Caption;
        //Label2.Caption:=Delete(S,1,1);
        Delete(S, 1, 1);
        Label2.Caption := S;
end;
Explanation: The first error occurred because the first parameter of the Delete function was of variable type, that is, reference type.
      The second error is because the Delete function has no return value, which is a procedure of type Procedure
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-12-20 17:00:01
| Show all posts
Thank you, big brother upstairs, the problem is solved, thank you so much!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list