Call <STRING AS COMMAND>

Hi, i have a textbox name txtCommand. When the user presses a button i want the txtCommand.text to call a sub ie

Call txtCommand.txt

but im not able to do that

How would i be able to do that instead of going

select case txtCommand.txt

case "Sub1"

call sub1()

case "Sub2"

call sub2()

end select

Thx




Answer this question

Call <STRING AS COMMAND>

  • Visual Basic Nov.

    What version of VB are you using

  • telectro

    2005 express

  • iSUBBU

    I would assume your trying to do the following for a button click event

     

    Public Class Form1
        Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Select Case TextBox1.Text
                Case "Sub1"
                    Call Sub1()
                Case "Sub2"
                    Call Sub2()
            End Select
        End Sub

        Sub Sub1()

        End Sub

        Sub Sub2()

        End Sub
    End Class


     or for a keypress while in the textbox control

     

    Public Class Form1

        Sub Sub1()

        End Sub

        Sub Sub2()

        End Sub

        Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
            Select Case TextBox1.Text
                Case "Sub1"
                    Call Sub1()
                Case "Sub2"
                    Call Sub2()
            End Select
        End Sub
    End Class


     

     


  • RLHegde

    I have always wanted to do this, and I was reading a C# book today that mentioned it. I think it was called reflection, and you could use it to interrogate libraries' metadata to find out procedure names dynamically and then call them. Which sounds very much like what you want to do.

    I'd suggest doing a search on reflection and "dynamic binding"

    - Scott


  • OpenBlue

    No that's exactly what im not trying to do . I just want to call the sub directly from the textbox



  • Call <STRING AS COMMAND>