|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vbScript eval() function equivalent in VB.Net - Dynamically evaluate codeI'd like to be able to evaluate some code dynamically in VB.Net. What I'd like to achieve especially is this: dim myForm as Form = new myDLLName.Form1 What I want really is the possibility to do this: dim x as string = "2" eval ("dim myForm as Form = new myDLLName.Form"+x) I was used to be able to do that in vbScript and found it was very practical and now I would like to be able to do it in VB.Net if possible. Any ideas or workaround? neilsanner <neilsan***@yahoo.com> schrieb:
> dim x as string = "2" <URL:http://dotnet.mvps.org/dotnet/code/techniques/#ClassByName>> eval ("dim myForm as Form = new myDLLName.Form"+x) > > I was used to be able to do that in vbScript and found it was very > practical and now I would like to be able to do it in VB.Net if > possible. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Hey thanks buddy!!! That's awesome!!! I don't speak german but thanks
to google translate I was able to figure it out. Here are my findings: Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim currentDomain As AppDomain = AppDomain.CurrentDomain 'Provide the current application domain evidence for the assembly. Dim asEvidence As Evidence = currentDomain.Evidence 'If we don't do this, it won't be able to find the assembly of our custom .dll library 'Load the assembly from the application directory using a simple name. 'Create the assembly currentDomain.Load("CustomDLL", asEvidence) 'Get the form Dim daForm As Form = DirectCast(CreateObject("CustomDLL", "CustomDLL.Form1"), System.Windows.Forms.Form) daForm.ShowDialog() End Sub Private Function CreateObject(ByVal AssemblyName As String, ByVal TypeName As String) As Object 'Make an array for the list of assemblies. Dim assems As [Assembly]() = AppDomain.CurrentDomain.GetAssemblies() 'Search for the assembly and return the object specified For Each asm As System.Reflection.Assembly In assems Console.WriteLine(asm.FullName) If asm.FullName.StartsWith(AssemblyName & ",") Then Return asm.CreateInstance(TypeName) End If Next asm End Function neilsanner Herfried K. Wagner [MVP] wrote: Show quoteHide quote > <neilsan***@yahoo.com> schrieb: > > dim x as string = "2" > > eval ("dim myForm as Form = new myDLLName.Form"+x) > > > > I was used to be able to do that in vbScript and found it was very > > practical and now I would like to be able to do it in VB.Net if > > possible. > > > <URL:http://dotnet.mvps.org/dotnet/code/techniques/#ClassByName> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/>
Comparing 2 datatables...
how do you execute javascript after script is regsistered? Dragging a file from Windows into My program Whats this Dynamic Menus with Events ComboBox Rounded form corners and a custom title bar how do I enable the scrollbars in my textbox drop down inside a datagrid example? (windows forms, not asp) Grouping and counting XML |
|||||||||||||||||||||||