Elegant way of handling a lot of variables ?
-
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
-
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
Use an array of edit controls. You can access each of them by it's index.
Owner drawn Jesus Loves
-
Use an array of edit controls. You can access each of them by it's index.
Owner drawn Jesus Loves
-
Oh that is interesting ! =) Can you give more details on how to do that ? I was looking for something like that... Thanks
//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
-
//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
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).
-
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).
Yeah.
Owner drawn Jesus Loves