Executing Visual Basic code from a string
Function _Function(ByVal ? As ?)
'This is where it is supposed to execute a function
?.Execute()
End Function
So can someone please help me?
Function _Function(ByVal ? As ?)
'This is where it is supposed to execute a function
?.Execute()
End Function
So can someone please help me?
Hi,
You can use Reflection and do something like this:
Public Sub CallMethod(ByVal strAssemblyName As String, ByVal strClassName As String, ByVal strMethodName As String) objAssembly = [Assembly].Load(strAssemblyName) |
Thanks,
Tanner
Public Class MyClass
Public MyFunction(Byval MyVal as string)as string
Dim MyReturnVal As String
....Do Something
Return MyReturnVal
end Function
Public Sub Test()
Dim MyOldString as String = "Test"
Dim MyNewString as string = MyFunction(MyOldString)
end sub
end class
Function exCodeString(ByVal Str As String) Execute code from string End Function Sub DoSomething() exCodeString("Me.Text = ""Somestring""") End Sub |
I need a simple way to do that.
Thanks,
Tanner
try
Function exCodeString (Byval str as string) as string Sub DoSomething() |
Yes, I need that to do it, I am using the other example for now, but I'd still like to know the textbox with executing code thing. It will improve my program by about 300% or so.
Nah, you missed what he's trying to say.
Here's an example of what he wants (I don't know how to do it, I'm curious myself.): say you have a form open and a textbox and button on the form, he wants it so in the textbox you can type valid VB.NET code and execute it as it displays.
For example: In this textbox, if I type in Me.Visible = False and click the execute button, it should execute the code and then hide the form.
Doesn't anybody know? There has to be a way to do it, last time I checked, Visual Basic .NET 2003 could do almost anything. I say almost remember. There has to be a way, because I saw a control on http://windowsforms.net that could allow you to execute VB code from a string. Please tell me an answer.