+ Reply to Thread
Results 1 to 10 of 10

Convert a String Name to Declared Boolean

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Convert a String Name to Declared Boolean

    Hi all,

    I'm wondering how if possible to convert a string to a Boolean
    For instance, normally someone would use:
    Please Login or Register  to view this content.
    However, I'd like to say something like the following.

    Please Login or Register  to view this content.
    Any Help is welcome.

    Thanks,

    BDB
    Last edited by bdb1974; 05-16-2012 at 12:05 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Convert a String Name to Declared Boolean

    I'm not sure but maybe
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Convert a String Name to Declared Boolean

    Please Login or Register  to view this content.

    Note that Choose is a reserved word (an Excel function) so I've added "s" for string.

    As z was not defined, I have defined it. It isn't set so, by default, it will be zero and, hence, not equal to 1 (one) and the value of sChoose won't change.

    TIM

  4. #4
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Convert a String Name to Declared Boolean

    Probably should have asked, why do you want a string variable to represent the value?

  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert a String Name to Declared Boolean

    if you want to use a string as the variable name, then no you can't. you could create a class with some properties (booleans) and then use your string to refer to those properties by name but I can't think of a reason why you would ;-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  6. #6
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Convert a String Name to Declared Boolean

    Thanks for both of your replies. The solutions provided are not quite what I was hoping to get.
    I don't think I phrased my question quite right to describe what actually I'm trying to do.
    Please let me try to reword my problem.

    "Check,Check2 and Check3 are already Publicly dimmed as Booleans" for the following:

    Please Login or Register  to view this content.
    I guess maybe MyBoolean could be a Function

  7. #7
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Convert a String Name to Declared Boolean

    Here's something I've come up with but still not what I'm wanting. I think I'm wanting to treat the Boolean as an object.

    Please Login or Register  to view this content.
    I'd like to shorten this if possible.
    Maybe the following is all I can do?
    Please Login or Register  to view this content.
    I'd like to shorten even further so as to avoid stating " if Z = then"
    z=1
    I'd like to just say: uck = True ' where uck is check
    Last edited by bdb1974; 05-16-2012 at 03:49 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    05-14-2012
    Location
    Unknown
    MS-Off Ver
    Unseen
    Posts
    429

    Re: Convert a String Name to Declared Boolean

    To be honest, I think you're going about it back to front. You have three boolean variables which may be true or false and one string variable that you want to reflect the boolean variable(s). so why not:

    Please Login or Register  to view this content.

    TIM

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Convert a String Name to Declared Boolean

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Convert a String Name to Declared Boolean

    TIM,
    Actually, what I'm trying to do I believe is impossible. I would like to set UCK to one of the 3 checks, like you can with objects. But,since the checks are Boolean, I can't. I guess, if I were to treat my CHECKs as strings, than I could say UCK = "CHECK=TRUE"/"CHECK2=TRUE"/"CHECK3=TRUE" Today I've run out of time, I'll look at this again tomorrow.

    Thanks,
    BDB

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1