Results 1 to 2 of 2

Thread: compare variables content to another variable name

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2010
    Posts
    2

    Post 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.

  2. #2
    Hyperactive Member Lenggries's Avatar
    Join Date
    Sep 2009
    Posts
    353

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width