compare variables content to another variable name
Ok i am not sure if i am making any sence and if what i am about to ask is possible but here it goes.
Lets assume that we have 5 variables n1, n2, n3, n4, n5 = 0 (boolean) and two more variables f1 = 2 and f2 = 4 (integer). Is it possible to somehow compare those numbers (2, 4) with the names n1, n2, n3, n4, n5 and in the cases that the number matches the number of the variables name to turn it to 1?
the result should be n1 = 0, n2 = 1, n3 = 0, n4 = 1, n5 = 0 ?
As you probable figured out i am not excactly an expert in vb.
Re: compare variables content to another variable name
I know you can do that in javascript with some clever manipulation of the eval() function, but I don't know of any ways in VB. However, what you can do is turn n into an array with an upper bound of 5. So instead of n1, n2, n3, n4, and n5, you have n(1), n(2), n(3), n(4), and n(5). So then you would just reference the correct index of n using your f variables:
Code:
n(f1) = 1
n(f2) = 1