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

    Home » Forums » Developers, developers, developers » DevOps Lounge » How to run a VB command statement in a string (VB .Net 2003)

    Author
    Topic
    #425503

    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

    Viewing 0 reply threads
    Author
    Replies
    • #980527

      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

      • #980530

        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.

    Viewing 0 reply threads
    Reply To: How to run a VB command statement in a string (VB .Net 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: