Results 1 to 2 of 2

Thread: Indirection in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    MD,USA
    Posts
    13

    Post

    How do I reference a variable indirectly? Is there a way to do something like this:

    var=Inputbox("Enter the variable to display")
    'imagine that "x" was entered"
    print ? '{the value of the variable named x)

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    The only way I can think of to do it is:
    Code:
    Select Case var
        Case "x"
            Print x
        Case "y"
            Print y
        Case "z"
            Print z
        Case Else
            MsgBox "Variable " & var & " not defined"
    End Select
    ------------------
    Marty

    [This message has been edited by MartinLiss (edited 12-08-1999).]

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