Getting a variable from string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paulos
    New Member
    • Jul 2006
    • 6

    Getting a variable from string

    Hi,

    I need to know how to get a variable name that is included in a string, eg. when I have a variable called Var1 and a string like this: "Var1".

    Thanks.
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    Originally posted by Paulos
    Hi,

    I need to know how to get a variable name that is included in a string, eg. when I have a variable called Var1 and a string like this: "Var1".

    Thanks.
    Your question is not clear. Do you mean, if you have string such as:

    "My Name is Paulos"

    and the code that created the string looks like this:

    Code:
    Dim sName as String
    Dim sStringToView as String
    
    sName = "Paulos"
    sStringToView = "My Name is " & sName
    MsgBox sStringToView
    You want to extract sName from sStringToView?

    Comment

    • Paulos
      New Member
      • Jul 2006
      • 6

      #3
      I can have the code like this:

      dim ARR() as integer
      dim str as string = "ARR"

      And I want to get ARR from this string, but as an array, not string.

      Comment

      • CaptainD
        New Member
        • Mar 2006
        • 135

        #4
        Originally posted by Paulos
        I can have the code like this:

        dim ARR() as integer
        dim str as string = "ARR"

        And I want to get ARR from this string, but as an array, not string.
        When you Dim str as String, VB allocates a space in memory to hold a single item. In the case above "ARR" and that is all. You can change the value of str but not change it's type. You can take it's value and add it to an array but the array has to be created at the time you dim it. I don't think you can convert a dim'd value that is not an array to an array,

        At least that is my understanding.

        Comment

        • c0ldfyr3
          New Member
          • Aug 2006
          • 1

          #5
          CallByName is your shining light.

          Comment

          • Paulos
            New Member
            • Jul 2006
            • 6

            #6
            Yes, it is indeed. Thank you.

            Comment

            Working...