Re: Text to FUnction Name
You can get the value of the text box. So after that use selct case.
Code:
Select Case gridTextBox.text
Case "ABC"
Call ABC()
Case "XYZ"
Call XYZ()
End Select
Re: Text to FUnction Name
Sorry, i should have mentioned,
this(cases) is what i am trying to avoid
Re: Text to FUnction Name
vb Code:
Imports System.Reflection
Public Class Form1
Sub Say(ByVal Arg1 As String, ByVal arg2 As String)
MsgBox(Arg1 & arg2)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim MethodName As String = "Say"
Dim Args() As String = {"Hello, ", "World"}
Dim thistype As Type = GetType(Form1)
Dim mi As MethodInfo = thistype.GetMethod(MethodName)
mi.Invoke(Me, Args)
End Sub
End Class
Re: Text to FUnction Name
Use
Code:
CallByName(Me, gridTextBox.text, CallType.Method)
Re: Text to FUnction Name
Quote:
Originally Posted by
aashish_9601
Sorry, i should have mentioned,
this(cases) is what i am trying to avoid
Even though cicatrix has given you an answer, why are you trying to avoid Select Case?
Code:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim wordsToExecute() As String = New String() {"one", "two", "three"} 'simulate hidden textbox values
For Each word As String In wordsToExecute
doWord(word)
Next
End Sub
Private Sub doWord(ByVal word As String)
Select Case word
Case "one"
Stop
Case "two"
Stop
Case "three"
Stop
End Select
End Sub
Re: Text to FUnction Name
Quote:
Originally Posted by
dbasnett
Even though cicatrix has given you an answer, why are you trying to avoid Select Case?
I second that. Select case is probably a better solution.