03-23-2016 10:00 AM
HI,
I have done a program. Here I just use 2 string control and give it to write to a spreadsheet file, to save what is typed in string control to the file. Now the file path to be given to write to spreadsheet file, I have to choose between two. My main motive of the program is choosing between the two. For that I used 2 buttons, enum and case structure and while loop. My doubt is can this be done in a better way than this. I need to use this in another program. Also there it is not choosing between two, but there are atleast 5. So I will have to use 5 buttons there. So can I do this in a more simple and better manner. I have uploaded the code. Thanking You in advance.
03-23-2016 10:07 AM
I don't doubt that it can be done better. Perhaps you have a question?
Try looking at radio buttons for choosing among different files. Instead of multiple select functions, the value from a radio button control can be wired to the index of an Index Array function. That array would be an array of file paths and it would index out whichever path you used at the moement.
03-23-2016 10:23 AM
There is no need to create two states for this. If you have only two choices, a single boolean is sufficient. (you only need two booleans if you have four possible options (no file, file 1, file 2, both files).
I would place all possible file names into a listbox and e.g. use a double-click event to act on it. Now things are scalable and the code can be used for any number of selections without any further change in code.
Learn how to use event structures. Currently your code hammers the CPU, spinning as fast as possible while repeating mostly the same operations over and over for no good reason at all. I would also not chop up the code so much. you could do the file IO in a state handling 1&2 directly.
03-28-2016 08:42 AM
Hi!
I agree that there are some things that are possible to tweak:
Best regards,
Christoph