Results 1 to 5 of 5

Thread: Evaluating Variables

  1. #1
    Adept Developer
    Guest

    Evaluating Variables

    Is it possible to force evaluation of variables.

    Example:

    strItem = "Index"

    Node.strItem

    Obviously strItem is not a property or method of the Node object, the value of strItem is. Is there a way to evaluate that line so that I actually get Node.Index?

    -Steve

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    You can use a variable to reference a member of a collection, like the Nodes collection. You can use either a numeric variable, which VB will interpret as the Index property or a string variable which will be interpreted as the Key property:
    Code:
    TreeView1.Nodes(strMyKey)
    "It's cold gin time again ..."

    Check out my website here.

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Steve,

    If Bruce's answer doesn't fufill your needs try this.

    The way I would approach it would be to take the string and just use a select statement to figure out which one you want and then reference the correct property or method.

    Hope this helps,

  4. #4
    Matthew Gates
    Guest
    Put this code in a Class module.


    VB Code:
    1. Public Property Get strItem() As Integer
    2.     strItem = sItem
    3. End Property
    4.  
    5. Public Property Let strItem(ByVal vNewValue As Integer)
    6.     sItem = vNewValue
    7. End Property


    And in a form:


    VB Code:
    1. Private Sub Form_Load()
    2.     Dim Node As Class1
    3.     Set Node = New Class1
    4.     Node.strItem = 0
    5.     MsgBox Node.strItem
    6.     Set Node = Nothing
    7. End Sub

  5. #5
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Matthew,

    I dont think thats what he was asking, I think he wanted to know how do do something like this.

    Code:
    strItem="Caption"
    Me.stritem = "This is my new caption"
    but then again I could be wrong.

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