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. Elegant way of handling a lot of variables ?

Elegant way of handling a lot of variables ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
6 Posts 3 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.
  • B Offline
    B Offline
    BeakX
    wrote on last edited by
    #1

    Hello all, Perhaps this is a rather idiotic question to ask..but i will ask anyway. I am writing a VC++ application with a lot of edit boxes (about a hundred >_<) and thus i have a lot of variables which go like PHASE1_1,PHASE1_2,PHASE1_3.....,PHASE2_1,PHASE2_2..PHASE3_1...etc i find that i have a programming nightmare when i attempt to retrive values from all of them as i have to type out their names individually. Is there any elegant way of handling A LOT of variables which are similar in name, such that it would make the program writing process a lot easier ? Thanks in advance

    O 1 Reply Last reply
    0
    • B BeakX

      Hello all, Perhaps this is a rather idiotic question to ask..but i will ask anyway. I am writing a VC++ application with a lot of edit boxes (about a hundred >_<) and thus i have a lot of variables which go like PHASE1_1,PHASE1_2,PHASE1_3.....,PHASE2_1,PHASE2_2..PHASE3_1...etc i find that i have a programming nightmare when i attempt to retrive values from all of them as i have to type out their names individually. Is there any elegant way of handling A LOT of variables which are similar in name, such that it would make the program writing process a lot easier ? Thanks in advance

      O Offline
      O Offline
      Owner drawn
      wrote on last edited by
      #2

      Use an array of edit controls. You can access each of them by it's index.


      Owner drawn Jesus Loves

      B 1 Reply Last reply
      0
      • O Owner drawn

        Use an array of edit controls. You can access each of them by it's index.


        Owner drawn Jesus Loves

        B Offline
        B Offline
        BeakX
        wrote on last edited by
        #3

        Oh that is interesting ! =) Can you give more details on how to do that ? I was looking for something like that... Thanks

        O 1 Reply Last reply
        0
        • B BeakX

          Oh that is interesting ! =) Can you give more details on how to do that ? I was looking for something like that... Thanks

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4
          //edit controls
          CEdit m_EditGroup[NUMBER_OF_EDITS_REQUIRED];
          //////////////////////////
          for(int index=0;index<NUMBER_OF_EDITS_REQUIRED;index++)
              m_EditGroup[index].Create(...);
          /////////////////////////
          //You can access all of them inside a loop like this...
          for(int index=0;index<NUMBER_OF_EDITS_REQUIRED;index+)
              m_EditGroup[index].FunctionName(...);//that's it
          

          Owner drawn Jesus Loves

          C 1 Reply Last reply
          0
          • O Owner drawn
            //edit controls
            CEdit m_EditGroup[NUMBER_OF_EDITS_REQUIRED];
            //////////////////////////
            for(int index=0;index<NUMBER_OF_EDITS_REQUIRED;index++)
                m_EditGroup[index].Create(...);
            /////////////////////////
            //You can access all of them inside a loop like this...
            for(int index=0;index<NUMBER_OF_EDITS_REQUIRED;index+)
                m_EditGroup[index].FunctionName(...);//that's it
            

            Owner drawn Jesus Loves

            C Offline
            C Offline
            Cedric Moonen
            wrote on last edited by
            #5

            Owner drawn wrote:

            CEdit m_EditGroup[NUMBER_OF_EDITS_REQUIRED];m_EditGroup.Create(...);

            Except that you have to create all the edit boxes (in a for loop).

            O 1 Reply Last reply
            0
            • C Cedric Moonen

              Owner drawn wrote:

              CEdit m_EditGroup[NUMBER_OF_EDITS_REQUIRED];m_EditGroup.Create(...);

              Except that you have to create all the edit boxes (in a for loop).

              O Offline
              O Offline
              Owner drawn
              wrote on last edited by
              #6

              Yeah.


              Owner drawn Jesus Loves

              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