1.

Solve : vba convert from string?

Answer»

I have a series of loops that determine the inputs into equations (the loop counter arrays are used) and I have another function that identifies the input conditions which chooses which loop counter array to used to define some variables. What I would LIKE to do is to be able to say that when some condition exists the loops will pick the right set of equations to use for the variables and then plug them in with out having to loop each time to redetermine the functions to be used.

If I could say something like the following:


sub loopy()

loop_array_1 = 1
loop_array_2 = 3


for loop_a = 0 to loop_array_1
for loop_b = 0 to loop_array_2
if loop_a * loop_b +loob_b >0 then
function_1 (loop_array_1, loop_array_2)
functions (output_counter)
end if
var_1
var_2
var_3
next loop_b
next loop_a

function_1(loop_array_1 as integer, loop_array_2 as integer)
select case loop_array_1
case 1
select case loo_array_2
case 2
output_counter = 1
case 3
output_counter = 2
end select
case 2
select case loo_array_2
case 1
output_counter = 3
case 3
output_counter = 4
end select
case 3
select case loo_array_2
case 1
output_counter = 5
case 2
output_counter = 46
end select
end select
end function

functions (output_counter as integer)
select case output_counter
case 1
var_1 = 1+loop_a*loop_b
var_2 = 1+loop_b-loop_a
var_3 = loop_a/loop_b
case 2
.......
......
.....
end select
end function

as stated above, I need to evaluate var_1, var_2, and var_3 each time the program loops, however I don't want to go to the trouble of the select cases to pick the new var_1,2,3 equations each time.

Is it possible to make the function portion a string and to then PULL it out and evaluate it numerically?
Thanks!Probably... err... let me think a while...

btw, whatever's wrong with that way?the downfall of the above method is that it will have to go back through and reselect the case each time in order to pick the right variables/equations to update for each run/loop. If I could leave the functions as a string of find some other way that once they have been selected they are pulled into the main for loop area that would be the best. Then I would have the right equations at the right spot without having to recalculate them each time. (I have 24 possible variable combinations hence 24 possible equation combinations.) I may end up leaving it as above and only selecting the "output_counter" once and then running the other "select case" each time. I haven't been able to find a way to pull an equation out of a string.

I am happy THOUGH, my vba now waits for a return signal from the command prompt that is shelled from vba to run a batch file. I am just trying to find ways to speed up the preprocessing of inputs. I would also like to KNOW if it is possible for future work that I may do.
ThanksI'm sure it is, but you'd need an equation. What you've GOT is fine. How much faster do you want it to go? .000001 of a second?



Discussion

No Comment Found