We help IT Professionals succeed at work.
Get Started

How to pass the name of a Bolean variable in a String Variable and setting the Boolean Variable True Using the String Variable.

310 Views
Last Modified: 2012-05-11

I have a Global Boolean variable in my project in Visual Basic. named    YesNo01
I wish to make it True through the Click event of a Button . However, instead of setting it True directly by using this Boolean Variable’s own name, I wish to set it True using a String Variable that is carrying its name.
So what I am looking for is something like this:

1.      Dim YesNo01 As Boolean
2.      Dim myString as String
3.      myString = “YesNo01”
4.      myString = True
I had hoped that the 4th line of code will make YesNo01 = True, but this does not work.
I wish to know if it is possible to achieve something like this. That is passing the name of one Boolean Variable in a String Variable and then setting the orginal Boolean variable true using that string variable. I hope I have been able to clarify my question.
Thank you for your help.

Best wishes

 
Comment
Watch Question
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE