![]() |
Incompatible types: 'String' and 'TStrings'
hallo :)
hab ein dummes problem :oops: ich hab ein script gefunden das eine http txt datei in ein memo lädt, das möchte ich dazu nutzen die aktuellste programm version anzuzeigen, nur ich möchte die version in einem label und nicht in einem memo feld anzeigen lassen! hier das script:
Delphi-Quellcode:
wenn ich "label4.Caption := memo1.lines;" in FormCreate mache, sagt er immer:
function download(url, pfad:string): Boolean;
begin Result := UrlDownloadToFile(nil, PChar(url), PChar(pfad), 0, nil) = 0; end; procedure TForm1.FormCreate(Sender: TObject); begin label4.Caption := memo1.lines; if download('http://www.server.net/version.txt',ExtractFilePath(Paramstr(0)) + 'datei.txt') then begin memo1.lines.loadfromfile(ExtractFilePath(Paramstr(0)) + 'datei.txt'); end else ShowMessage('Fehler beim Download!'); end; [Error] Incompatible types: 'String' and 'TStrings' Wie mache ich das jetzt ? :lol: [edit=sakura]Delphi-Tags eingefügt. Mfg, sakura[/edit] |
Re: Incompatible types: 'String' and 'TStrings'
Lines ist ja auch vom Typ TStrings.
Memos haben aber noch eine weitere Eigenschaft: Text. Chris [edit]Schnellster! :mrgreen:[/edit] |
Re: Incompatible types: 'String' and 'TStrings'
Moin Quakergod,
dann mach mal:
Delphi-Quellcode:
label4.Caption := memo1.lines.text;
|
Re: Incompatible types: 'String' and 'TStrings'
Ist auch logisch, weil halt TString <> String ist...
Nun gut versuch mal Label1.Caption := Memo1.Text. So sollte es funktionieren [edit]Wieso komme ich eigentlich immer zu spät? :? :mrgreen:[e/dit] |
Re: Incompatible types: 'String' and 'TStrings'
label4.Caption ist vom Typ String, wärend memo1.lines vom Typ TStrings ist, die kannst Du natürlich nicht direkt zuweisen.
Dafür gibt es die Eigenschaft Text von TMemo. Aber warum möchtest Du das ganze in einem TLabel darstellen? Außerdem weist Du den Inhalt von Memo1 erst Label4 zu und lädst dann neuen Inhalt in Memo1. Außerdem gibt es die Tags [ delphi] und [ /delphi], damit kannst Du deinen Source besser hervorheben. [edit]Zu langsam.[/edit] |
Re: Incompatible types: 'String' and 'TStrings'
Mal so als Abschluss: Seit wann ist die Caption von Typ String :?:
Bei mir steht da immer der Typ TCaption, welcher wiederum als string definiert ist. :mrgreen: Immer diese Krümmelkac..r :roll: ...:cat:... |
Re: Incompatible types: 'String' and 'TStrings'
hui, vielen dank für eure hilfe! (funktioniert super)
eine sache wüsste ich aber noch gerne... if label2.caption ungleich memo1.lines.text then ... wie schreib ich das in 'delphi' ? :bouncing4: |
Re: Incompatible types: 'String' and 'TStrings'
NUTZE BITTE DIE DELPHI-TAGS :!: :!: :!:
Delphi-Quellcode:
...:cat:...
if label2.caption <> memo1.lines.text then
|
Re: Incompatible types: 'String' and 'TStrings'
sorry, dachte mein gekritzel wäre kein delphi :roll:
danke aber, hat super gefunzt und ich hab jetzt ne tolle möglichkeit die programmversion zu checken! :D |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:27 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz