case statements within event handlers

This is a discussion on case statements within event handlers within the C++ Programming forums, part of the General Programming Boards category; Hi, i need some urgent help. I have created a simple windows app- the idea is that there are 5 ...

  1. #1
    millie
    Guest

    Unhappy case statements within event handlers

    Hi,

    i need some urgent help. I have created a simple windows app- the idea is that there are 5 lights that are all of to begin with, and then turn on as you click the Next button, one after the other (as in, they go from black to yellow).
    Now, my idea was to use a variable, state, that has values 0-5- with each click increasing the value of state by 1. I then plan to use a case step causing the visual changes to happen depending on the value of state.

    here's an exmaple:

    switch (state)
    {
    case '1' : Shape1->Color = clYellow; break;
    etc.
    }

    It's coming back with an "undefined symbol 'Shape1'. I'm a beginner so have no idea what you can and can't use within case statements within event handlers.

    I'm using Borland C++ Builder 5 if that helps.

    Thanks

    Neile

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    You can use case statements. The error message is telling you that Shape1 is not defined, spelling error somewhere? missing declaration? missing header file?

    Attach your whole source plus any non standard headers and resource scripts, (enough so I can compile it), if you need more help. If you want to attach more than one file, zip them together and attach the .zip.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Sounds to me like a variable that is not in scope. Post your code though, and it'll be easier to help.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  2. Can someone please clean up my code
    By ki113r in forum C Programming
    Replies: 10
    Last Post: 09-12-2007, 11:03 AM
  3. Efficiency of case statements
    By Yasir_Malik in forum C Programming
    Replies: 26
    Last Post: 05-23-2006, 12:36 PM
  4. Problem with simple case statements
    By shoobsie in forum C Programming
    Replies: 2
    Last Post: 05-08-2006, 09:39 AM
  5. Converting Numbers to Words
    By denizengt in forum C Programming
    Replies: 20
    Last Post: 11-05-2003, 09:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21