<?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[Taschenrechner nur pder keys]]></title><description><![CDATA[<p>Huhu...</p>
<p>sagt mal ist das eine gute Idee, einen Taschenrechner zu programmieren?</p>
<p>Also Idee: nur 1 Edit zur Eingabe, und berechnung aufgrund von Keydown:</p>
<p>Hier mal beispiel für addition:</p>
<pre><code class="language-cpp">void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &amp;Key,
      TShiftState Shift)
{
if (Key == VK_ADD)
 {
  a = Edit1-&gt;Text;
  Edit1-&gt;Clear();
 }
if (Key == VK_RETURN)
 {
 b = Edit1-&gt;Text;
 b= StringReplace(b,&quot;+&quot;,&quot;&quot;,TReplaceFlags()&lt;&lt;rfReplaceAll);
 a1 = StrToInt(a);
 b1 = StrToInt(b);
 b2 = a1+b1;
 Label1-&gt;Caption=b2;

 }
}
</code></pre>
<p>für Verbesserungsvorschläge bin ich immer zu gebrauchen!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/98038/taschenrechner-nur-pder-keys</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 23:27:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/98038.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 15 Jan 2005 22:41:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 22:41:23 GMT]]></title><description><![CDATA[<p>Huhu...</p>
<p>sagt mal ist das eine gute Idee, einen Taschenrechner zu programmieren?</p>
<p>Also Idee: nur 1 Edit zur Eingabe, und berechnung aufgrund von Keydown:</p>
<p>Hier mal beispiel für addition:</p>
<pre><code class="language-cpp">void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &amp;Key,
      TShiftState Shift)
{
if (Key == VK_ADD)
 {
  a = Edit1-&gt;Text;
  Edit1-&gt;Clear();
 }
if (Key == VK_RETURN)
 {
 b = Edit1-&gt;Text;
 b= StringReplace(b,&quot;+&quot;,&quot;&quot;,TReplaceFlags()&lt;&lt;rfReplaceAll);
 a1 = StrToInt(a);
 b1 = StrToInt(b);
 b2 = a1+b1;
 Label1-&gt;Caption=b2;

 }
}
</code></pre>
<p>für Verbesserungsvorschläge bin ich immer zu gebrauchen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697623</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sat, 15 Jan 2005 22:41:23 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 22:51:45 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>bedient sich dann wohl so ähnlich wie ein konventieller Taschenrechner, schätze ich. Als Übung in Ordnung, aber immerhin sitzen wir ja vor einem großen Bildschirm, und denn kannst du doch auch nutzen. Also ruhig die Tasten mit Buttons anzeigen, die Hotkeys kannste ja drinelassen. Ideen wäre eine Anzeige der Zwischenwerte in einer seperaten ListBox.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697634</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 15 Jan 2005 22:51:45 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:00:54 GMT]]></title><description><![CDATA[<p>2 probleme noch:</p>
<p>1: wie kann ich mehrere Operationen einbinden, also nicht nur ADD..sondern auch DIV etc....da das RETURN ja nur auf ADD funktioniert</p>
<p>2: wie kann ich die berechnung &quot;weiterlaufen&quot; lassen, also hier kann ich ja nur einmal &quot;+&quot; drücken, beim 2 mal wird ja nicht auf das ergebniss von der ersten addition aufgerechnet, sondern nur auf den ersten eingebenen wert!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697643</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697643</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:12:19 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>du must dir einfach Operationstyp (z.b. durch ein eigenes enum) und Wert in Membervariablen des Forms zwischenspeichern und beim Enter wieder vorholen und auswerten.</p>
<p>bis bald<br />
akair</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697651</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:12:19 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:31:11 GMT]]></title><description><![CDATA[<p>versuche deine berechnung etwas dynamischer zu gestallten<br />
zB im Stil von</p>
<pre><code class="language-cpp">if (Key == VK_ADD)
 {
    switch(Operator)
    {
        case '+':
            a = a + StrToInt(Edit1-&gt;Text);
        break;
        case '-':
            a = a - StrToInt(Edit1-&gt;Text);
        break;
        case '/':
            a = a / StrToInt(Edit1-&gt;Text);
        break;
        case '*':
            a = a * StrToInt(Edit1-&gt;Text);
        break;
        default:
            a = StrToInt(Edit1-&gt;Text);
    }
    operator = '+';

  Edit1-&gt;Clear();
 }
</code></pre>
<p>das ganze natürlich mit allen entsprechenden tasten <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/UserInput/VirtualKeyCodes.asp" rel="nofollow">&quot;+-*/&quot;</a></p>
<p>also code wurde nicht getestet und ist nur so ne idee.. kann auch voller fehler sein..</p>
<p>mfg BigNeal</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697657</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:31:11 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:30:57 GMT]]></title><description><![CDATA[<p>Ja, indem man beim drueken der plustaste (VK_ADD), alle berechnungen machen kann ;)!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697660</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697660</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:30:57 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:31:48 GMT]]></title><description><![CDATA[<p>@ akari, kannst mir mal ein beispiel geben....bitte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/697663</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697663</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:31:48 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:33:20 GMT]]></title><description><![CDATA[<p>Kopffrau_oder_mann schrieb:</p>
<blockquote>
<p>Ja, indem man beim drueken der plustaste (VK_ADD), alle berechnungen machen kann ;)!</p>
</blockquote>
<p>?? was meinst du jetzt damit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697664</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:33:20 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sat, 15 Jan 2005 23:39:26 GMT]]></title><description><![CDATA[<p>Ich glaube mal, das Sie/Er meint, das bei deinem Code ja erst nach dem drueken der PLUSTASTE der switsch ausgeführt wird!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697671</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697671</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Sat, 15 Jan 2005 23:39:26 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 00:32:23 GMT]]></title><description><![CDATA[<p>ich habe jetzt mal kurz einen taschenrechner getestet mit meinem codebeispiel..<br />
es funktioniert tipptopp soweit.<br />
ich berechne einfach bei jedem operator der eingetippt wird die rechnung vorher..<br />
also bei 1+5-6=<br />
beim - wird 1+5 berechnet und zwischengespeichert und beim = den zwischenspeicher-6</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697706</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697706</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sun, 16 Jan 2005 00:32:23 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 14:22:29 GMT]]></title><description><![CDATA[<p>@ Big, bei deinem Beispiel bekomme ich einen fehler, &quot;Überladbarer Operator erwartet&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/697983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/697983</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sun, 16 Jan 2005 14:22:29 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 14:40:14 GMT]]></title><description><![CDATA[<p>ich glaube so dürfte es funktionieren:</p>
<pre><code class="language-cpp">public:		// Anwender-Deklarationen
        char Operator;
        int a;
</code></pre>
<pre><code class="language-cpp">void __fastcall TForm1::Edit1KeyDown(TObject *Sender, WORD &amp;Key,
      TShiftState Shift)
{

if (Key == RETURN)
 {
    switch(Operator)
    {
        case '+':
            a = a + StrToInt(Edit1-&gt;Text);
        break;
        case '-':
            a = a - StrToInt(Edit1-&gt;Text);
        break;
        case '/':
            a = a / StrToInt(Edit1-&gt;Text);
        break;
        case '*':
            a = a * StrToInt(Edit1-&gt;Text);
        break;
        default:
            a = StrToInt(Edit1-&gt;Text);
    }
    Operator = '+';

  Edit1-&gt;Clear();
  Label1-&gt;Caption=a;
 };

}
</code></pre>
<p>berichtigt mich wenn ich falsch liege!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698005</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Sun, 16 Jan 2005 14:40:14 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 14:44:22 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>wenn es funktioniert, ist es richtig, also einfach mal ausprobieren!<br />
Ich würde aber einen besseres Namen für eine so wichtige Variable wie a nehmen, z.B. Value.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698015</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 16 Jan 2005 14:44:22 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 15:01:07 GMT]]></title><description><![CDATA[<p>Na funktioniert net...da bei VK_RETURN das &quot;+&quot; mit im String bleibt und er dann meckert, das +324324 kein Integerwert ist!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698036</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Sun, 16 Jan 2005 15:01:07 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 15:46:27 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich hab mal ein wenig rumgespielt. Um das so hinzukriegen, wir ihr es wollt, mußt ihr :<br />
- statt Edit1-&gt;OnKeyDown den Event Form1-&gt;OnShortCut nehmen<br />
- Form1-&gt;KeyPreview auf true stellen<br />
- in Form1ShortCut dies kopieren</p>
<pre><code class="language-cpp">int NewValue;

  switch(Msg.CharCode)
  {
    case VK_ADD :
    case VK_SUBTRACT :
    case VK_DIVIDE :
    case VK_MULTIPLY :
    case VK_RETURN :
      NewValue = StrToIntDef(Edit1-&gt;Text, 0);
      Handled = true;
      if (NewValue == 0) return;
      switch(Operator)
      {
        case VK_ADD:
          a = a + NewValue;
          break;
        case VK_SUBTRACT:
          a = a - NewValue;
          break;
        case VK_DIVIDE:
          a = a / NewValue;
          break;
        case VK_MULTIPLY :
          a = a * NewValue;
          break;
        default:
          a = NewValue;
        };
      if (Msg.CharCode != VK_RETURN)
      {
        Operator = Msg.CharCode;
        Edit1-&gt;Clear();
        }
      Label1-&gt;Caption=a;
      break;
    };
</code></pre>
<p>dann habt ihr einen Rechner, wie ihr es wollt. Sind noch ein paar Schwächen, aber ansonsten...</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698064</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698064</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 16 Jan 2005 15:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 15:54:59 GMT]]></title><description><![CDATA[<p>also hier mal mein beispiel von gestern abend</p>
<pre><code class="language-cpp">void __fastcall TForm1::Berechnen()
{

    switch(cRechnungsOperator)
    {
        case '+':
            dTemp = dTemp + StrToInt(Edit1-&gt;Text);
        break;
        case '-':
            dTemp = dTemp - StrToInt(Edit1-&gt;Text);
        break;
        case '/':
            dTemp = dTemp / StrToInt(Edit1-&gt;Text);
        break;
        case '*':
            dTemp = dTemp * StrToInt(Edit1-&gt;Text);
        break;
        default:
            dTemp = StrToInt(Edit1-&gt;Text);
    }
}                  

void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &amp;Key)
{
   if (Key == '+')
   {
      Berechnen();
      cRechnungsOperator = '+';
      Edit1-&gt;Clear();
      Key = NULL;
   }
   if (Key == '-')
   {
      Berechnen();
      cRechnungsOperator = '-';
      Edit1-&gt;Clear();
      Key = NULL;
   }
   if (Key == '/')
   {
      Berechnen();
      cRechnungsOperator = '/';
      Edit1-&gt;Clear();
      Key = NULL;
   }
   if (Key == '*')
   {
      Berechnen();
      cRechnungsOperator = '*';
      Edit1-&gt;Clear();
      Key = NULL;
   }
   if (Key == 13)
   {
      Berechnen();
      Label1-&gt;Caption = AnsiString(dTemp);
      Edit1-&gt;Clear();
      Key = NULL;
      cRechnungsOperator = 0;
   }
}
</code></pre>
<p>falls jemand eine beschreibung braucht werde ich das noch nachholen</p>
<p>[Edit] wobei natürlich</p>
<pre><code class="language-cpp">char cRechnungsOperator;
double dTemp;
</code></pre>
<p>in der .h steht [/Edit]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698070</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sun, 16 Jan 2005 15:54:59 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 17:06:50 GMT]]></title><description><![CDATA[<p>ja also ich hätte schon gern eine beschreibung...=)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698115</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sun, 16 Jan 2005 17:06:50 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 20:33:47 GMT]]></title><description><![CDATA[<p>damit es auch einen möglichst hohen lehrnefekt hat, sagst du am besten was du verstehst und was nicht.. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/698272</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698272</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sun, 16 Jan 2005 20:33:47 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 21:28:25 GMT]]></title><description><![CDATA[<p>ok, du legst funktion an, wo dTemp der Wert in Edit1 ist, und dann ein schalter, wo je nach operator der alte mit dem neuen berechnet wird!</p>
<p>Im programm wertest du Keypress aus, und übergibst den keys die jeweiligen operatoren! ODER?</p>
<p>Mit Key 13 verstehe ich nicht!</p>
<p>Wenn ich oben schon was falsch verstanden habe, sag es bitte!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698353</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698353</guid><dc:creator><![CDATA[Kopffrau_oder_mann]]></dc:creator><pubDate>Sun, 16 Jan 2005 21:28:25 GMT</pubDate></item><item><title><![CDATA[Reply to Taschenrechner nur pder keys on Sun, 16 Jan 2005 23:01:35 GMT]]></title><description><![CDATA[<p>ich mach mal ein beispiel.. wieder dass &quot;1+5-6=&quot;</p>
<p>wenn eine die &quot;1&quot; eingegeben wird passiert nichts spezieles<br />
kommt der erste RechnungsOperator das &quot;+&quot; da wird in der if schleife die funktion &quot;berechnen()&quot; aufgerufen.<br />
da noch nichts im RechnungsOperator steht und erste eine zahl eingegeben wurde(zum berechnen brauchs ja für die 4 grundoperationen immer 2 zahlen) wird default aufgerufen. d.h. der wert im edit wird zwischengespeichert in dTemp<br />
durch Edit1-&gt;Clear() wird der inhalt des edits gelöscht und der Wert in &quot;Key&quot;(das zeichen das ins Edit feld übergeben wird) wird auch gelöscht, so dass nichts mehr im edit steht.<br />
bei der zweiten zahl die &quot;5&quot; passiert wieder nichts<br />
beim &quot;-&quot; wird wieder das entsprechende if aufgerufen<br />
berechnet wird die erste zahl mit dem operator mit der zweitern zahl momentan im edit</p>
<pre><code class="language-cpp">dTemp + StrToInt(Edit1-&gt;Text);
</code></pre>
<p>und das ganze wird wieder in dTemp geschrieben.<br />
dann halt man &quot;die erste zahl&quot; gespeichert.. da immer das zwischenresultat berechnet wird und der letzte operator auch.. so kann man immer weiter rechnen ohne an ein ende zu kommen.<br />
beim enterschlag</p>
<pre><code class="language-cpp">if (Key == 13)
   {
      Berechnen();
      Label1-&gt;Caption = AnsiString(dTemp);
      Edit1-&gt;Clear();
      Key = NULL;
      cRechnungsOperator = 0;
   }
</code></pre>
<p>wird nochmals das resultat berechnet, das in einem label ausgegeben, wieder alles löschen inkl RechnungsOperator</p>
<p>hoffe das war verständlich..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/698387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/698387</guid><dc:creator><![CDATA[BigNeal]]></dc:creator><pubDate>Sun, 16 Jan 2005 23:01:35 GMT</pubDate></item></channel></rss>