Re: read first character in Delphi


[ DelphiLand FAQ ]

Posted by matt on July 28, 2004 at 18:22:18:

In Reply to: Re: read first character in Delphi posted by webmaster Guido on July 28, 2004 at 15:11:04:

Yes. Thanks.

: ---------------------

: In Delphi, the Caption of a label is of the type "string", so it only can contain a string, not another type like for example an integer number

: So, the following two lines can not work, because already the first line would give an error when you try to compile it:

: Label1.Caption := 2323; // wrong, 2323 is not a string
: Initial := Label1.Caption[1];

: But the following is OK:

: Label1.Caption := '2323'; // OK, '2323' is a string
: Initial := Label1.Caption[1];

: If you want to show a number in a caption, you first have to convert it to a string. Example:

: var
: Initial : string;
: N: integer;
: begin
: N := 2323;
: // Convert integer N to a string
: // and show that string in the label
: Label1.Caption := IntToStr(N);
: // Read first character of the Caption
: Initial := Label1.Caption[1];

: Does this answer your question?


[ DelphiLand FAQ ]