Autor Beitrag
blackbirdXXX

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Di 01.04.03 17:37 
Hallo,
ich habe da eine Frage. Wie kann ich herausfinden was in der letzten Zeile einer memo Komponente steht und diese Zeile dann in einen String stecken?

Freue mich über jede Antwort

_________________
Klein, schwarz und ärgert Techniker? Jumper!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 01.04.03 17:43 
Mit
ausblenden Quelltext
1:
Memo1.Lines.Count;					

Bekommst du die Anzahl der Zeilen im Memo.
blackbirdXXX Threadstarter

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Di 01.04.03 17:50 
Das weiß ich schon aber ich habe mein Problem so gehabt:

ausblenden Quelltext
1:
if memo1.Lines.Objects[memo1.Lines.Count] = 'test' then					


Leider spuckt mir der Complier dann folgende Meldung aus:
[Error] Chat4.pas(586): Incompatible types: 'String' and 'TObject'

Was habe ich da falsch?[/code]

_________________
Klein, schwarz und ärgert Techniker? Jumper!
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 01.04.03 17:54 
Probiers mal mit
ausblenden Quelltext
1:
Memo1.Lines[Memo1.Lines.count-1].Text;					


wen ichs grad richtig im Kopp hab
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 01.04.03 17:58 
TMemo.Lines ist vom Typ TStrings. Die einzlenen Zeilen eines TStrings sind vom Typ String und werden über einen Index angesprochen. Mit memo1.lines[i] bekommst Du also eine Zeile als String.

memo1.lines.count gibt Dir zwar die Anzahl der Zeilen, jedoch startet die Nummerierung dieser Zeilen bei Null, der letzte zulässige Index ist also memo1.lines.count-1.

MfG,
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
blackbirdXXX Threadstarter

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Di 01.04.03 18:08 
Bringt leider keine Veränderung.
Was meint der mit:
[Error] Chat4.pas(586): Incompatible types: 'String' and 'TObject'?
Kann ich denn einen TObject String machen?

_________________
Klein, schwarz und ärgert Techniker? Jumper!
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 01.04.03 18:12 
Was bringt keine Veränderung?
ausblenden Quelltext
1:
2:
3:
4:
5:
var
  s : String;
begin
  s := Memo1.Lines.Strings[Memo1.Lines.Count-1];
  Showmessage(s);
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Di 01.04.03 18:15 
Hatte einen kleinen Fehler drin:
ausblenden Quelltext
1:
Memo1.Lines.Strings[Memo1.Lines.Count-1];					

damit funktionierts

Lines selbst ist nämlich eine Art StringList, deswegen gehts net mit Lines[i]
blackbirdXXX Threadstarter

ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1077
Erhaltene Danke: 1

Ubuntu Dapper

BeitragVerfasst: Di 01.04.03 18:52 
:D Danke. Jetzt funktioniert es. :D

_________________
Klein, schwarz und ärgert Techniker? Jumper!