<?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[timer]]></title><description><![CDATA[<p>Hallo,<br />
ich habe versucht einen timer_2 zu progen, welcher nach 5 Sekunden einen Zufallsbuchstaben auf einem Label ausgeben soll.<br />
Wer kann mir helfen, das ist die letzte Aufgabe in meinem Fernstudium,juchuuuuuu <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Danke!!!!!</p>
<p>class __Form1_declspec Form1 : public __Form1_Base<br />
{</p>
<pre><code class="language-cpp">public:       // add your public instance data here
    private:      // add your private instance data here

        clock_t                         startZeit, stopZeit;

        WULong                          timerTicks,timer2Ticks ;
        WDouble                         warte;
    protected:    // add your protected instance data here

};

// Code added here will be included at the top of the .CPP file

//  Include definitions for resources.
#include &quot;WRes.h&quot;

Form1::Form1()
{
}

Form1::~Form1()
{
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::Schaltflaeche_1_Click(
    WObject *           source,
    WEventData *        event )
{
    WString                  sBuchstabe;
    char                     cBuchstabe;
    WDouble                  zufall;

    label_3-&gt;SetText( &quot;&quot; );
    label_13-&gt;SetText( &quot;&quot; );

    timerTicks = 0;
    timer_1-&gt;Start( 100,0 );
    startZeit = clock();

    srand (clock());
    zufall = rand();
    cBuchstabe = ((int) zufall % 26);
    cBuchstabe = cBuchstabe + 'a';
    sBuchstabe.Sprintf(&quot;%c&quot;, cBuchstabe);
    label_4-&gt;SetText( sBuchstabe);

    Textfeld_1-&gt;SetText( &quot;&quot; );
    Textfeld_1-&gt;SetFocus( );

    return FALSE;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::timer_1_Timer(
    WObject *               source,
    WTimerEventData *       event )
{
     timerTicks++;         // Zaehler bei jedem Timer-Ereignis inkrementieren
    return FALSE;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*                Reagieren auf eine Aenderung des Textfeld-Inhaltes       */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::Textfeld_1_Change(
    WObject *           source,
    WEventData *        event )
{
    WString                         text1, text2;
    WString                         string_diffZeit;
    WDouble                         diffZeit;

    text1 = Textfeld_1-&gt;GetText();  
    if (text1 == &quot;&quot;)                
    {
       return FALSE;               
    }
   text2 = label_4-&gt;GetText();      // Entspricht der Inhalt des Textfeldes  
    if (text1 == text2)              // dem im Label 4?
    {                                // Ja!

      timer_1-&gt;Stop();
      stopZeit = clock();

      diffZeit = (stopZeit - startZeit);
      diffZeit = diffZeit / CLOCKS_PER_SEC;

      string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);
      label_3-&gt;SetText( string_diffZeit );

      diffZeit = timerTicks / 10.0;

      string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);
      label_13-&gt;SetText( string_diffZeit );

    }
    else                             // Entspricht der Inhalt des Textfeldes  
    {                                // dem im Label 4?
        Textfeld_1-&gt;SetText( &quot;&quot; );   // Nein: Text löschen
    }

    return FALSE;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::timer_2_Timer(
	WObject *        		source,
	WTimerEventData *		event )
{

    WString                  sBuchstabe;
    char                     cBuchstabe;
    WDouble                  zufall;
 WDouble                         diffZeit;
     timer2Ticks++;

    if (timer2Ticks &gt; warte)
    {
    timerTicks = 0;
    timer_1-&gt;Start( 100,0 );
    startZeit = clock();

    srand (clock());
    zufall = rand();
    cBuchstabe = ((int) zufall % 26);
    cBuchstabe = cBuchstabe + 'a';
    sBuchstabe.Sprintf(&quot;%c&quot;, cBuchstabe);

    diffZeit = timerTicks / 10000000.0;
    label_4-&gt;SetText( sBuchstabe);

    Textfeld_1-&gt;SetText( &quot;&quot; );
    Textfeld_1-&gt;SetFocus( );

    timer_2-&gt;Stop();
    timer2Ticks = 0;
    }
    return FALSE;
</code></pre>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162286/timer</link><generator>RSS for Node</generator><lastBuildDate>Sat, 12 Sep 2026 03:02:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162286.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Oct 2006 09:40:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to timer on Tue, 17 Oct 2006 09:40:29 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe versucht einen timer_2 zu progen, welcher nach 5 Sekunden einen Zufallsbuchstaben auf einem Label ausgeben soll.<br />
Wer kann mir helfen, das ist die letzte Aufgabe in meinem Fernstudium,juchuuuuuu <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Danke!!!!!</p>
<p>class __Form1_declspec Form1 : public __Form1_Base<br />
{</p>
<pre><code class="language-cpp">public:       // add your public instance data here
    private:      // add your private instance data here

        clock_t                         startZeit, stopZeit;

        WULong                          timerTicks,timer2Ticks ;
        WDouble                         warte;
    protected:    // add your protected instance data here

};

// Code added here will be included at the top of the .CPP file

//  Include definitions for resources.
#include &quot;WRes.h&quot;

Form1::Form1()
{
}

Form1::~Form1()
{
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::Schaltflaeche_1_Click(
    WObject *           source,
    WEventData *        event )
{
    WString                  sBuchstabe;
    char                     cBuchstabe;
    WDouble                  zufall;

    label_3-&gt;SetText( &quot;&quot; );
    label_13-&gt;SetText( &quot;&quot; );

    timerTicks = 0;
    timer_1-&gt;Start( 100,0 );
    startZeit = clock();

    srand (clock());
    zufall = rand();
    cBuchstabe = ((int) zufall % 26);
    cBuchstabe = cBuchstabe + 'a';
    sBuchstabe.Sprintf(&quot;%c&quot;, cBuchstabe);
    label_4-&gt;SetText( sBuchstabe);

    Textfeld_1-&gt;SetText( &quot;&quot; );
    Textfeld_1-&gt;SetFocus( );

    return FALSE;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::timer_1_Timer(
    WObject *               source,
    WTimerEventData *       event )
{
     timerTicks++;         // Zaehler bei jedem Timer-Ereignis inkrementieren
    return FALSE;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*                Reagieren auf eine Aenderung des Textfeld-Inhaltes       */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::Textfeld_1_Change(
    WObject *           source,
    WEventData *        event )
{
    WString                         text1, text2;
    WString                         string_diffZeit;
    WDouble                         diffZeit;

    text1 = Textfeld_1-&gt;GetText();  
    if (text1 == &quot;&quot;)                
    {
       return FALSE;               
    }
   text2 = label_4-&gt;GetText();      // Entspricht der Inhalt des Textfeldes  
    if (text1 == text2)              // dem im Label 4?
    {                                // Ja!

      timer_1-&gt;Stop();
      stopZeit = clock();

      diffZeit = (stopZeit - startZeit);
      diffZeit = diffZeit / CLOCKS_PER_SEC;

      string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);
      label_3-&gt;SetText( string_diffZeit );

      diffZeit = timerTicks / 10.0;

      string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);
      label_13-&gt;SetText( string_diffZeit );

    }
    else                             // Entspricht der Inhalt des Textfeldes  
    {                                // dem im Label 4?
        Textfeld_1-&gt;SetText( &quot;&quot; );   // Nein: Text löschen
    }

    return FALSE;
}
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

WBool Form1::timer_2_Timer(
	WObject *        		source,
	WTimerEventData *		event )
{

    WString                  sBuchstabe;
    char                     cBuchstabe;
    WDouble                  zufall;
 WDouble                         diffZeit;
     timer2Ticks++;

    if (timer2Ticks &gt; warte)
    {
    timerTicks = 0;
    timer_1-&gt;Start( 100,0 );
    startZeit = clock();

    srand (clock());
    zufall = rand();
    cBuchstabe = ((int) zufall % 26);
    cBuchstabe = cBuchstabe + 'a';
    sBuchstabe.Sprintf(&quot;%c&quot;, cBuchstabe);

    diffZeit = timerTicks / 10000000.0;
    label_4-&gt;SetText( sBuchstabe);

    Textfeld_1-&gt;SetText( &quot;&quot; );
    Textfeld_1-&gt;SetFocus( );

    timer_2-&gt;Stop();
    timer2Ticks = 0;
    }
    return FALSE;
</code></pre>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156132</guid><dc:creator><![CDATA[Renate]]></dc:creator><pubDate>Tue, 17 Oct 2006 09:40:29 GMT</pubDate></item><item><title><![CDATA[Reply to timer on Tue, 17 Oct 2006 09:55:15 GMT]]></title><description><![CDATA[<p>Und? Wo ist nun dein Problem? (außer daß du timer_1 mit einem Intervall von 0 startest?)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156141</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 17 Oct 2006 09:55:15 GMT</pubDate></item><item><title><![CDATA[Reply to timer on Tue, 17 Oct 2006 10:39:05 GMT]]></title><description><![CDATA[<p>CStoll schrieb:</p>
<blockquote>
<p>Und? Wo ist nun dein Problem? (außer daß du timer_1 mit einem Intervall von 0 startest?)</p>
</blockquote>
<p>Hallo,</p>
<p>der Zufallsbuchstabe soll auf Label_4 ausgegeben werden, mit einer Verzögerung von 5 Sekunden und dafür benötige ich den timer_2.<br />
Was meinst Du &quot;timer_1 mit einem Intervall von 0 startest&quot;<br />
Ausgegeben wird ja ein Zufallsbuchstabe schon nur jetzt soll er eben mit einer Verzögerung von 5 Sekunden ausgegeben werden.<br />
Alles 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>
]]></description><link>https://www.c-plusplus.net/forum/post/1156176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156176</guid><dc:creator><![CDATA[Renate]]></dc:creator><pubDate>Tue, 17 Oct 2006 10:39:05 GMT</pubDate></item><item><title><![CDATA[Reply to timer on Tue, 17 Oct 2006 10:48:45 GMT]]></title><description><![CDATA[<p>Renate schrieb:</p>
<blockquote>
<p>der Zufallsbuchstabe soll auf Label_4 ausgegeben werden, mit einer Verzögerung von 5 Sekunden und dafür benötige ich den timer_2.</p>
</blockquote>
<p>Kann sein, daß ich es übersehen habe - aber wer startet eigentlich den timer_2?</p>
<p>(ich kenne mich mit der Timer-Programmierung deines Systems (btw, was für ein Compiler ist das überhaupt) nicht so gut aus, aber ich tippe darauf, daß timer_2_Timer() aufgerufen wird, wenn er bei 0 ankommt)</p>
<blockquote>
<p>Was meinst Du &quot;timer_1 mit einem Intervall von 0 startest&quot;</p>
</blockquote>
<p>Das hier:</p>
<blockquote>
<pre><code class="language-cpp">timer_1-&gt;Start( 100,0 );
</code></pre>
</blockquote>
<p>Du verwendest dort den Komma-Operator (ich vermute, das soll eigentlich ein Dezimalpunkt werden).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156182</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 17 Oct 2006 10:48:45 GMT</pubDate></item><item><title><![CDATA[Reply to timer on Tue, 17 Oct 2006 11:14:18 GMT]]></title><description><![CDATA[<p>Hallo danke,</p>
<p>jetzt funkts, anbei der code jetzt passts</p>
<p>VIELEN DANK!!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>// Declarations added here will be included at the top of the .HPP file</p>
<p>class __Form1_declspec Form1 : public __Form1_Base<br />
{</p>
<p>public: // add your public instance data here<br />
private: // add your private instance data here</p>
<p>clock_t startZeit, stopZeit;</p>
<p>WULong timerTicks,timer2Ticks ;<br />
WDouble warte;<br />
protected: // add your protected instance data here</p>
<p>};</p>
<p>// Code added here will be included at the top of the .CPP file</p>
<p>// Include definitions for resources.<br />
#include &quot;WRes.h&quot;</p>
<p>Form1::Form1()<br />
{<br />
}</p>
<p>Form1::~Form1()<br />
{<br />
}</p>
<p>/<em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</em>/</p>
<p>WBool Form1::Schaltflaeche_1_Click(<br />
WObject * source,<br />
WEventData * event )<br />
{<br />
label_3-&gt;SetText( &quot;&quot; );<br />
label_13-&gt;SetText( &quot;&quot; );<br />
label_4-&gt;SetText( &quot;&quot; );<br />
Textfeld_1-&gt;SetText( &quot;&quot; );</p>
<p>srand (clock());<br />
warte = int(rand() %40);<br />
warte = (warte + 10);</p>
<p>timer_2-&gt;Start( 100,0 );</p>
<p>return FALSE;<br />
}</p>
<p>/<em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</em>/</p>
<p>WBool Form1::timer_1_Timer(<br />
WObject * source,<br />
WTimerEventData * event )<br />
{<br />
timerTicks++; // Zaehler bei jedem Timer-Ereignis inkrementieren<br />
return FALSE;<br />
}<br />
/<em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</em>/<br />
/* Reagieren auf eine Aenderung des Textfeld-Inhaltes <em>/<br />
/</em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/</p>
<p>WBool Form1::Textfeld_1_Change(<br />
WObject * source,<br />
WEventData * event )<br />
{<br />
WString text1, text2;<br />
WString string_diffZeit;<br />
WDouble diffZeit;</p>
<p>text1 = Textfeld_1-&gt;GetText();<br />
if (text1 == &quot;&quot;)<br />
{<br />
return FALSE;<br />
}<br />
text2 = label_4-&gt;GetText(); // Inhalt des Textfeld<br />
if (text1 == text2) // gleich Label 4?<br />
{ // Ja!<br />
timer_1-&gt;Stop();<br />
stopZeit = clock();</p>
<p>diffZeit = (stopZeit - startZeit);<br />
diffZeit = diffZeit / CLOCKS_PER_SEC;</p>
<p>string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);<br />
label_3-&gt;SetText( string_diffZeit );</p>
<p>diffZeit = timerTicks / 10.0;</p>
<p>string_diffZeit.Sprintf(&quot;%4.2f&quot;,diffZeit);<br />
label_13-&gt;SetText( string_diffZeit );<br />
}<br />
else // Inhalt des Textfeld<br />
{ // gleich Label 4?<br />
Textfeld_1-&gt;SetText( &quot;&quot; ); // Nein: Text löschen<br />
}</p>
<p>return FALSE;<br />
}<br />
/<em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</em>/</p>
<p>WBool Form1::timer_2_Timer(<br />
WObject * source,<br />
WTimerEventData * event )<br />
{</p>
<p>WString sBuchstabe;<br />
char cBuchstabe;<br />
WDouble zufall;</p>
<p>timer2Ticks++;</p>
<p>if (timer2Ticks &gt; warte)<br />
{<br />
timerTicks = 0;<br />
timer_1-&gt;Start( 100,0 );<br />
startZeit = clock();</p>
<p>srand (clock());<br />
zufall = rand();<br />
cBuchstabe = ((int) zufall % 26);<br />
cBuchstabe = cBuchstabe + 'a';<br />
sBuchstabe.Sprintf(&quot;%c&quot;, cBuchstabe);<br />
label_4-&gt;SetText( sBuchstabe);</p>
<p>Textfeld_1-&gt;SetText( &quot;&quot; );<br />
Textfeld_1-&gt;SetFocus( );</p>
<p>timer_2-&gt;Stop();<br />
timer2Ticks = 0;<br />
}<br />
return FALSE; }<br />
/<em>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</em>/</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1156200</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1156200</guid><dc:creator><![CDATA[Renate]]></dc:creator><pubDate>Tue, 17 Oct 2006 11:14:18 GMT</pubDate></item></channel></rss>