<?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[wxwidgets TextCtrl eingabe speichern!]]></title><description><![CDATA[<p>Hallo,<br />
Wenn ich die eingabe als Wert speichern möchte geht das nicht !</p>
<pre><code>string zahl = textctrl-&gt;GetValue();
   string zahl2 = textctrl2-&gt;GetValue();
   string summe = zahl + zahl2;
   statictext-&gt;SetLabel(summe);
</code></pre>
<p>Wenn ich jetzt 1 und 2 eingebe kommt als Lösung 12 und nicht 3 ?<br />
Und wenn ich die Variablen als integer speicher kommt dieser Fehler :</p>
<pre><code>C:\Users\AirTrake\Documents\wxwidgets\base.cpp||In member function 'void BasicFrame::OnClickButtonOK(wxCommandEvent&amp;)':|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|65|error: invalid conversion from 'const wxChar*' to 'int'|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|66|error: invalid conversion from 'const wxChar*' to 'int'|
C:\CodeBlocks\wxWidgets-2.8.12\include\wx\string.h|682|error: 'wxString::wxString(int)' is private|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|68|error: within this context|
||=== Build finished: 4 errors, 0 warnings ===|
</code></pre>
<p>Mit Freundlichen Grüssen</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/296416/wxwidgets-textctrl-eingabe-speichern</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 21:51:00 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/296416.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Dec 2011 15:07:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to wxwidgets TextCtrl eingabe speichern! on Sun, 04 Dec 2011 15:07:31 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Wenn ich die eingabe als Wert speichern möchte geht das nicht !</p>
<pre><code>string zahl = textctrl-&gt;GetValue();
   string zahl2 = textctrl2-&gt;GetValue();
   string summe = zahl + zahl2;
   statictext-&gt;SetLabel(summe);
</code></pre>
<p>Wenn ich jetzt 1 und 2 eingebe kommt als Lösung 12 und nicht 3 ?<br />
Und wenn ich die Variablen als integer speicher kommt dieser Fehler :</p>
<pre><code>C:\Users\AirTrake\Documents\wxwidgets\base.cpp||In member function 'void BasicFrame::OnClickButtonOK(wxCommandEvent&amp;)':|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|65|error: invalid conversion from 'const wxChar*' to 'int'|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|66|error: invalid conversion from 'const wxChar*' to 'int'|
C:\CodeBlocks\wxWidgets-2.8.12\include\wx\string.h|682|error: 'wxString::wxString(int)' is private|
C:\Users\AirTrake\Documents\wxwidgets\base.cpp|68|error: within this context|
||=== Build finished: 4 errors, 0 warnings ===|
</code></pre>
<p>Mit Freundlichen Grüssen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2152813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2152813</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 04 Dec 2011 15:07:31 GMT</pubDate></item><item><title><![CDATA[Reply to wxwidgets TextCtrl eingabe speichern! on Sun, 04 Dec 2011 15:35:59 GMT]]></title><description><![CDATA[<p>du kannst nicht mit strings rechnen. du musst sie davor umrechnen:</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;

int to_int(const std::string&amp; value)
{
  std::stringstream ss;
  ss &lt;&lt; value;

  int ret_val;
  ss &gt;&gt; ret_val;
  return ret_val;
}

std::string to_string(int value)
{
  std::stringstream ss;
  ss &lt;&lt; value;

  std::string ret_val;
  ss &gt;&gt; ret_val;
  return ret_val;
}
</code></pre>
<pre><code class="language-cpp">int zahl = to_int(textctrl-&gt;GetValue());
   string summe = to_string(zahl + zahl);
   statictext-&gt;SetLabel(summe);
</code></pre>
<p>wie du siehst, ändern sich nur die typen, der rest bleibt, also kannst du auch ein template draus machen:</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;

template &lt;typename OUT, typename IN&gt;
OUT convert(const IN&amp; value)
{
  std::stringstream ss;
  ss &lt;&lt; value;

  OUT ret_val;
  ss &gt;&gt; ret_val;
  return ret_val;
}
</code></pre>
<pre><code class="language-cpp">int zahl = convert&lt;int&gt;(textctrl-&gt;GetValue());
   string summe = convert&lt;std::string&gt;(zahl + zahl);
   statictext-&gt;SetLabel(summe);
</code></pre>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2152837</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2152837</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sun, 04 Dec 2011 15:35:59 GMT</pubDate></item><item><title><![CDATA[Reply to wxwidgets TextCtrl eingabe speichern! on Sun, 04 Dec 2011 15:54:14 GMT]]></title><description><![CDATA[<p>So muss es sein !<br />
Es klappt ich bedanke mich sehr !</p>
<p>Mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2152850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2152850</guid><dc:creator><![CDATA[Cho++]]></dc:creator><pubDate>Sun, 04 Dec 2011 15:54:14 GMT</pubDate></item></channel></rss>