Well, I need to create an xml file and write tags to it. I created the xml file as normal creation of a text file, but with the extension .xml and using these operators
First approach
a.writeline("<root>") if (check_boxapp.value = true ) then a.writeline("<condition>value</condition>") end if if (check_boxname.value = true ) then a.writeline("<condition>value1</condition>") end if
like these, and I have about 50 if the statements are .20 for <condition> tags and another 5 for someother tag and another 2 for naming the tag. So I canβt go for the status of a switch case. My question is that this slows down the execution of the vba macro, because for everyone, if statment Im gets access to the file. I check the condition and access the file, so this slows down the performance. This is my first approach.
Second approach
creating an array and tracking the status of the flags in the array, and then at the end, loop through the array, if it has 1, then use writeline else dont. sort of
if chechk_box.value = true then a(i) = 1 end if and at the end for i = 1 to 20 if(a(i)=1) then a.writeline("something") end if next i for i = 1 to 10 if(a(i)=1) then a.writeline("something") end if next i
Maybe I think I have about 6 cycles. In this approach, I create an array and use 50 statuses and then 6 for loops. I believe that creating an array eats memory, as well as the code is small in comparison with the first one, and also a little difficult to understand.
But I'm not sure which one would be faster. Please help with this or any other smart way, much appreciated
source share