Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi String - TString (https://www.delphipraxis.net/16330-string-tstring.html)

Snooze 15. Feb 2004 14:36


String - TString
 
Hallo,

habe das Problem, dass ich nicht weiß, wie ich das beheben kann.

ich deklariere ne Variable als string

hier mal ein Code-Ausschnitt:

Delphi-Quellcode:
ii := form4.Table1['EintragsNr'];
 form4.Table1.First;
 i:=0;
 while i <> ii do
  iii:= form4.table1['Datum'];
  [color=red]DBComboBox1.items:= DBComboBox1.items + iii;[/color]
  i:=i+1;
da meldet er:

Incompatible types: 'String' and 'TString'

Danke für Hilfe

Stefan

Chewie 15. Feb 2004 14:43

Re: String - TString
 
iii wird wohl ein String sein, DBComboBox1.items ist vom Typ TStrings. Die kann man nicht so verknüpfen.
Wenn du der Stringliste den String iii hinzufügen willst, musst du die Methode Add von TStrings benutzen.

Snooze 15. Feb 2004 14:49

Re: String - TString
 
und wie mache ich das?

sorry, bin leider in diesem Gebiet ein Vollnewbie :oops:

Benedikt 15. Feb 2004 14:54

Re: String - TString
 
Wie Chewie sagte:
Nimm die Methode Add von TStrings, z.b:

Delphi-Quellcode:
DBComboBox1.items.Add('diesundjenes');

fkerber 15. Feb 2004 14:54

Re: String - TString
 
Hi!

Mit der Methode Add:

Delphi-Quellcode:
DBCombobox1.Items.Add(iii);
Ciao fkerber

:oops: Zu langsam ....

Snooze 15. Feb 2004 14:56

Re: String - TString
 
danke, aber dann kriege ich als neue Meldung:

Incompatible types: 'TString' and 'Integer'

fkerber 15. Feb 2004 14:57

Re: String - TString
 
Hi!

Dann ist iii wohl kein String.
Dann musst du vorher noch

Delphi-Quellcode:
iiii:=inttostr(iii);
machen und dann eben iiii adden.

Ciao fkerber

neolithos 15. Feb 2004 14:57

Re: String - TString
 
IntToStr(iii);

Benedikt 15. Feb 2004 14:58

Re: String - TString
 
Was für einen Typ hat iii denn?
Wenn es ein Integer ist, dann schreib halt

Delphi-Quellcode:
DBCombobox1.Items.Add(IntToStr(iii));

fkerber 15. Feb 2004 15:00

Re: String - TString
 
Hi!

Oder einfach:

Delphi-Quellcode:
DBCombobox1.Items.Add(inttostr(iii));
Ciao fkerber

:oops: gott bin ich langsam

Snooze 15. Feb 2004 15:00

Re: String - TString
 
hm iii ist zu 100% ein String

Delphi-Quellcode:
private
    iii: string;
  public
    { Public declarations }
  end;

Snooze 15. Feb 2004 15:01

Re: String - TString
 
Zitat:

Zitat von fkerber
Hi!

Oder einfach:

Delphi-Quellcode:
DBCombobox1.Items.Add(inttostr(iii));
Ciao fkerber

:oops: gott bin ich langsam


geht nicht

dann schreibt er nähmlich, dass es keine Methode gibt, die dies erlauben würde

fkerber 15. Feb 2004 15:02

Re: String - TString
 
Hi!

Also wenn iii ein Integer ist geht das und sonst dürfte er nicht schreiben, dass es inkompatible Typen sind.

Kannst ja mal das Projekt anhängen.

Ciao fkerber

Snooze 15. Feb 2004 15:09

Re: String - TString
 
so habe mal mit absicht gesagt, dass iii integer ist

Meldung ohne Umwandlung:

incompatible types: 'integer' and 'string'

Meldung mit Umwandlung:

incompatible types: 'tstring' and 'string'

wenn iii String ist

Meldung ohne Umwandlung:

incompatible types: 'tstring' and 'string'

Meldung mit Umwandlung:

there is no overloaded version of 'IntToStr' that can be called with these arguments

Benedikt 15. Feb 2004 15:15

Re: String - TString
 
Zeig doch nochmal deine komplette Codestelle dort, oder häng die Unit mal an, wie fkerber schon sagte.

Snooze 15. Feb 2004 15:17

Re: String - TString
 
Liste der Anhänge anzeigen (Anzahl: 1)
danke

Benedikt 15. Feb 2004 15:23

Re: String - TString
 
Schon ist klar wo der Fehler liegt:

Es darf nicht heißen
DBComboBox1.items:= DBComboBox1.items.add(inttostr(iii));

sondern nur
DBComboBox1.items.add(inttostr(iii));

Außerdem denke ich, muss der Inhalt deiner While-Schleife noch in ein Begin und End, so z.B.

Delphi-Quellcode:
  while i <> ii do
  begin
    iii:= form4.table1['Datum'];
    DBComboBox1.items:= DBComboBox1.items.add(inttostr(iii));
    i:=i+1;
  end;

fkerber 15. Feb 2004 15:24

Re: String - TString
 
HI!

Nur zu Klarheit:
Die Schleife muss so aussehen:

Delphi-Quellcode:
while i <> ii do
  begin
    iii:= form4.table1['Datum'];
    DBComboBox1.items.add(inttostr(iii));
    i:=i+1;
  end;

Da war der Fehler ja noch immer drin @Benedikt.

Ciao fkerber

Snooze 15. Feb 2004 15:25

Re: String - TString
 
danke jetzt klappts. :-D

Benedikt 15. Feb 2004 15:26

Re: String - TString
 
Mist,

erst schreib ich wie es richtig sein soll, und dann in der Schleife vergess ich es zu ändern :wall:


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:41 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz