<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Telefonbuch]]></title><description><![CDATA[<p>Moin</p>
<p>ich habe vor, mir ein kleines Telfonbuch zu schreiben, in dem Nummern von Personen gespeichert werden.</p>
<p>Bisher funktioniert alles ziehmlich gut, bis auf die Tatsache, dass immer nur ein Wert eingelesen werden kann.</p>
<p>Hier der Quelltext:</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#pragma hdrstop
#include &lt;direct.h&gt;
#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TStringList *userName = new TStringList();

  userName-&gt;Add(Name-&gt;Text.c_str());
  userName-&gt;SaveToFile(&quot;Name&quot;);

  delete userName;

  TStringList *userNummer = new TStringList();

  userNummer-&gt;Add(Nummer-&gt;Text.c_str());
  userNummer-&gt;SaveToFile(&quot;Nummer&quot;);

  delete userNummer;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  TStringList *list = new TStringList();

  list-&gt;LoadFromFile(&quot;Name&quot;);

  for (int z = 0; z &lt; list-&gt;Count; ++z)
  {
    ListBox1-&gt;AddItem(list-&gt;Strings[z], 0);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
 TStringList *list_nr = new TStringList();
list_nr-&gt;LoadFromFile(&quot;Nummer&quot;);

for (int i = 0; i &lt; ListBox1-&gt;Items-&gt;Count; i++)
{
  if (ListBox1-&gt;Selected[i])
  {
    Panel1-&gt;Caption = list_nr-&gt;Strings[i];
  }
}
}
</code></pre>
<p>Ich glaube das ist so, weil ich keine Verbidung zwichen den in &quot;Name&quot; und in &quot;Nummer&quot; gespeicherten Informationen habe.</p>
<p>Kann mir jemand helfen ?</p>
<p>Danke schon mal im Vorraus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/159738/telefonbuch</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 02:42:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159738.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 18 Sep 2006 13:31:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Telefonbuch on Mon, 18 Sep 2006 13:31:06 GMT]]></title><description><![CDATA[<p>Moin</p>
<p>ich habe vor, mir ein kleines Telfonbuch zu schreiben, in dem Nummern von Personen gespeichert werden.</p>
<p>Bisher funktioniert alles ziehmlich gut, bis auf die Tatsache, dass immer nur ein Wert eingelesen werden kann.</p>
<p>Hier der Quelltext:</p>
<pre><code class="language-cpp">#include &lt;vcl.h&gt;
#pragma hdrstop
#include &lt;direct.h&gt;
#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TStringList *userName = new TStringList();

  userName-&gt;Add(Name-&gt;Text.c_str());
  userName-&gt;SaveToFile(&quot;Name&quot;);

  delete userName;

  TStringList *userNummer = new TStringList();

  userNummer-&gt;Add(Nummer-&gt;Text.c_str());
  userNummer-&gt;SaveToFile(&quot;Nummer&quot;);

  delete userNummer;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  TStringList *list = new TStringList();

  list-&gt;LoadFromFile(&quot;Name&quot;);

  for (int z = 0; z &lt; list-&gt;Count; ++z)
  {
    ListBox1-&gt;AddItem(list-&gt;Strings[z], 0);
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
 TStringList *list_nr = new TStringList();
list_nr-&gt;LoadFromFile(&quot;Nummer&quot;);

for (int i = 0; i &lt; ListBox1-&gt;Items-&gt;Count; i++)
{
  if (ListBox1-&gt;Selected[i])
  {
    Panel1-&gt;Caption = list_nr-&gt;Strings[i];
  }
}
}
</code></pre>
<p>Ich glaube das ist so, weil ich keine Verbidung zwichen den in &quot;Name&quot; und in &quot;Nummer&quot; gespeicherten Informationen habe.</p>
<p>Kann mir jemand helfen ?</p>
<p>Danke schon mal im Vorraus <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1139627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1139627</guid><dc:creator><![CDATA[schnurres]]></dc:creator><pubDate>Mon, 18 Sep 2006 13:31:06 GMT</pubDate></item><item><title><![CDATA[Reply to Telefonbuch on Mon, 18 Sep 2006 13:37:30 GMT]]></title><description><![CDATA[<p>Ich würde ein richtiges telefonbuchprogramm mit einer kleinen db im hintergrund schreiben</p>
<p>und vor dem speichern solltest du die gesamte datei in die stringlist laden, neue informationen da anhängen, und dann wieder in die datei speichern (überschreiben)!</p>
<p>irgendwie komm ich mit deiner lösung nicht so richtig klar.... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>auch würde ich viell ein struct oder eine class für das sammeln der daten (name, nummern etc..) verwenden</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1139631</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1139631</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Mon, 18 Sep 2006 13:37:30 GMT</pubDate></item><item><title><![CDATA[Reply to Telefonbuch on Mon, 18 Sep 2006 14:00:47 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich würde auch eine vernünftige DB bevorzugen.</p>
<p>Aber selbst wenn du bei Textdateien bleiben willst, dann nimm wenigstens eine einzelne <a href="http://de.wikipedia.org/wiki/CSV-Datei" rel="nofollow">CSV-Datei</a> anstatt für jede Spalte (Name und Nummer) eine eigene Datei.</p>
<p>Desweiteren solltest du deinen Controls sinnvolle Namen geben, denn Methoden namens Button1Click bis Button3Click sind nicht sehr aussagekräftig.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1139645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1139645</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Mon, 18 Sep 2006 14:00:47 GMT</pubDate></item></channel></rss>