Results 1 to 5 of 5

Thread: Reading a variable whoose name is in another variable

  1. #1

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090

    Reading a variable whoose name is in another variable

    Lets say I have
    VB Code:
    1. Type Step
    2.     x As Byte
    3.     y As Byte
    4.     up As Boolean
    5.     down As Boolean
    6.     left As Boolean
    7.     right As Boolean
    8. End Type
    9.  
    10. Dim a As String
    11. Dim cell22 As Step
    12. cell22.x = 1
    13. cell22.y = 5
    14. cell22.up = True
    15. cell22.down = False
    16. cell22.left = False
    17. cell22.right = True
    18.  
    19. a = "cell22"

    how can I msgbox the variable whoose name is in a?
    in JavaScript it would be: eval(a).x, but I know VB doesn't have eval(), so What can I do?
    Have I helped you? Please Rate my posts.

  2. #2

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    OK. Now this question isn't urgent as I've found another way of solving the problem (using arrays). Still being curious though, how can this be done?
    Have I helped you? Please Rate my posts.

  3. #3
    Addicted Member Psychotic's Avatar
    Join Date
    May 2004
    Posts
    164
    Do you want to put the value of the variable that is contained in a in a msgbox or do u want to put put the name of the variable thats in a in a msgbox? I don't think that you would be able to put the value of the variable in because the variable is a string so if you did somthing like....

    VB Code:
    1. msgbox a

    Then you would get the text from the variable... "Cell22"

    So....unless theres another way that I am unaware of then its not possible to put the value of a variable thats contained in a variable in a msgbox.
    -Psychotic-

  4. #4

    Thread Starter
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    ok, well it's a good thing I thought to use arrays then.
    Have I helped you? Please Rate my posts.

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    If you add the MS script control then you could do things like that, but it would have to be in the scope of the script.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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