Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. using timers

using timers

Scheduled Pinned Locked Moved C / C++ / MFC
c++questiondebugginghelplearning
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajveer
    wrote on last edited by
    #1

    I'm looking at "Sams Teach Yourself Visual C++ 6 in 21 Days" and for the code on page 78, I get the following error for line 23's code in the book: --------------------Configuration: Timers - Win32 Debug-------------------- Compiling... TimersDlg.cpp C:\WINDOWS\Desktop\Rajveer\Timers\TimersDlg.cpp(203) : error C2196: case value '1' already used Error executing cl.exe. TimersDlg.obj - 1 error(s), 0 warning(s) I checked all my code for that entire project and I've typed it exactly as the book. So what is wrong?

    RaviBeeR N 3 Replies Last reply
    0
    • R Rajveer

      I'm looking at "Sams Teach Yourself Visual C++ 6 in 21 Days" and for the code on page 78, I get the following error for line 23's code in the book: --------------------Configuration: Timers - Win32 Debug-------------------- Compiling... TimersDlg.cpp C:\WINDOWS\Desktop\Rajveer\Timers\TimersDlg.cpp(203) : error C2196: case value '1' already used Error executing cl.exe. TimersDlg.obj - 1 error(s), 0 warning(s) I checked all my code for that entire project and I've typed it exactly as the book. So what is wrong?

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      Um... hard to say without seeing some code. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

      N 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        Um... hard to say without seeing some code. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

        N Offline
        N Offline
        Nish Nishant
        wrote on last edited by
        #3

        Ravi Bhavnani wrote: hard to say without seeing some code The operative word here is "some" I guess. I mean we dont want someone posting an entire project over here huh? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

        J 1 Reply Last reply
        0
        • R Rajveer

          I'm looking at "Sams Teach Yourself Visual C++ 6 in 21 Days" and for the code on page 78, I get the following error for line 23's code in the book: --------------------Configuration: Timers - Win32 Debug-------------------- Compiling... TimersDlg.cpp C:\WINDOWS\Desktop\Rajveer\Timers\TimersDlg.cpp(203) : error C2196: case value '1' already used Error executing cl.exe. TimersDlg.obj - 1 error(s), 0 warning(s) I checked all my code for that entire project and I've typed it exactly as the book. So what is wrong?

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Post the code snippet for the function within which you get this error. Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

          1 Reply Last reply
          0
          • N Nish Nishant

            Ravi Bhavnani wrote: hard to say without seeing some code The operative word here is "some" I guess. I mean we dont want someone posting an entire project over here huh? Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

            J Offline
            J Offline
            Jamie Hale
            wrote on last edited by
            #5

            Not again. :) J

            N 1 Reply Last reply
            0
            • J Jamie Hale

              Not again. :) J

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #6

              :-) yeah. Not so soon anyway :-) Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut

              1 Reply Last reply
              0
              • R Rajveer

                I'm looking at "Sams Teach Yourself Visual C++ 6 in 21 Days" and for the code on page 78, I get the following error for line 23's code in the book: --------------------Configuration: Timers - Win32 Debug-------------------- Compiling... TimersDlg.cpp C:\WINDOWS\Desktop\Rajveer\Timers\TimersDlg.cpp(203) : error C2196: case value '1' already used Error executing cl.exe. TimersDlg.obj - 1 error(s), 0 warning(s) I checked all my code for that entire project and I've typed it exactly as the book. So what is wrong?

                RaviBeeR Offline
                RaviBeeR Offline
                RaviBee
                wrote on last edited by
                #7

                [ Please don't send me email - instead reply to the forum. Thanks! ] Rajveer wrote: Here is the function that gave the error. I have marked the line where the error occured. And i've pasted the error message below.

                void CTimersDlg::OnTimer(UINT nIDEvent)
                {
                // TODO: Add your message handler code here and/or call default
                CTime curTime = CTime::GetCurrentTime();
                switch(nIDEvent)
                {
                case ID_CLOCK_TIMER:
                m_sTime.Format("%d:%d:%d", curTime.GetHour(), curTime.GetMinute(),
                curTime.GetSecond());
                break;

                case ID\_COUNT\_TIMER:         ///THE ERROR OCCURED ON THIS LINE!!!///
                	m\_iCount++;
                	m\_sCount.Format("%d", m\_iCount);
                	break;
                }
                
                UpdateData(FALSE);
                
                CDialog::OnTimer(nIDEvent);
                

                }

                You can't have 2 cases (i.e. 2 occurences of ID_CLOCK_TIMER) in the same switch statement. Looks like you made a simple copy/paste error. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

                S 1 Reply Last reply
                0
                • RaviBeeR RaviBee

                  [ Please don't send me email - instead reply to the forum. Thanks! ] Rajveer wrote: Here is the function that gave the error. I have marked the line where the error occured. And i've pasted the error message below.

                  void CTimersDlg::OnTimer(UINT nIDEvent)
                  {
                  // TODO: Add your message handler code here and/or call default
                  CTime curTime = CTime::GetCurrentTime();
                  switch(nIDEvent)
                  {
                  case ID_CLOCK_TIMER:
                  m_sTime.Format("%d:%d:%d", curTime.GetHour(), curTime.GetMinute(),
                  curTime.GetSecond());
                  break;

                  case ID\_COUNT\_TIMER:         ///THE ERROR OCCURED ON THIS LINE!!!///
                  	m\_iCount++;
                  	m\_sCount.Format("%d", m\_iCount);
                  	break;
                  }
                  
                  UpdateData(FALSE);
                  
                  CDialog::OnTimer(nIDEvent);
                  

                  }

                  You can't have 2 cases (i.e. 2 occurences of ID_CLOCK_TIMER) in the same switch statement. Looks like you made a simple copy/paste error. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

                  S Offline
                  S Offline
                  solex
                  wrote on last edited by
                  #8

                  He doesn't - he as ID_CLOCK_TIMER and ID_COUNT_TIMER but they both seem to have the same value. A vast majority of our imports comes from outside the country. George W. Bush

                  RaviBeeR 1 Reply Last reply
                  0
                  • S solex

                    He doesn't - he as ID_CLOCK_TIMER and ID_COUNT_TIMER but they both seem to have the same value. A vast majority of our imports comes from outside the country. George W. Bush

                    RaviBeeR Offline
                    RaviBeeR Offline
                    RaviBee
                    wrote on last edited by
                    #9

                    Ooops! Sorry, my dyslexia got the better of me. :) /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups