Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to run a VB command statement in a string (VB .Net 2003)

    I am relearning Visual Basic and am doing an execise that requires me to add a child node to a TreeView object from the node currently selected. I have determined the selected node, and, by looping back through the node levels, have built up the required Add string. FYI, it is as follows:

    "TreeView1.Nodes(0).Nodes(1).Nodes.Add(New TreeNode("New Node Name")"

    Now that I have that command in a string variable, how to I execute it?

    Thank you for your time,

    John Littell

  2. #2
    3 Star Lounger
    Join Date
    May 2002
    Location
    Florence, Oregon, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to run a VB command statement in a string

    Thank you Hans for your reply. I could not get the Set nod = statement to work and VB would not accept the tvwChild constant, but I finally got the following to work:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Node As System.Windows.Forms.TreeNode
    Node = TreeView1.SelectedNode
    TextBox1.Text = InputBox(Prompt:="Enter name for new child of " & TreeView1.SelectedNode.Text)
    Node.Nodes.Add(TextBox1.Text)
    End Sub

    Regards, John

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: How to run a VB command statement in a string

    I posted a reply assuming that your question was about VB6. When I saw that it was about .Net, I removed my reply (since it was not relevant) and moved the thread to the .Net forum.

Posting Permissions

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