Eval函数vb.net [英] Eval function vb.net
问题描述
是否可以在VB.NET 2005中的代码中输入一个字符串,它将在运行时作为代码行执行?
? br />
即我想根据字符串声明一个新表格:
" Dim frm as new frmTest"
Thanx
Hi,
is it possible to enter a string in code in VB.NET 2005 which will be
executed as a codeline during runtime?
i.e. I want to declare a new form depending on the string:
"Dim frm as new frmTest"
Thanx
推荐答案
" Maurice" < HM ***** @ nospam.nospam> schrieb
"Maurice" <hm*****@nospam.nospam> schrieb
是否可以在VB.NET 2005中的代码中输入一个字符串,它将在运行时作为代码行执行?
即我想根据字符串声明一个新表单:
" Dim frm as new frmTest"
Hi,
is it possible to enter a string in code in VB.NET 2005 which will
be executed as a codeline during runtime?
i.e. I want to declare a new form depending on the string:
"Dim frm as new frmTest"
这一行是其中的一部分方法,类,命名空间,汇编?
也许上面两个问题的答案有帮助。
或:(框架1.1)
http:/ /msdn.microsoft.com/library/de...assemblies.asp
Armin
This line is to be part of which method, class, namespace, assembly?
Maybe the answers to the 2 questions above help.
Or: (Framework 1.1)
http://msdn.microsoft.com/library/de...assemblies.asp
Armin
" Armin Zingler < AZ ******* @ freenet.de>写在
新闻:uD ************** @ TK2MSFTNGP12.phx.gbl:
"Armin Zingler" <az*******@freenet.de> wrote in
news:uD**************@TK2MSFTNGP12.phx.gbl:
http://msdn.microsoft.com/library /de...y/en-us/cpguid
http://msdn.microsoft.com/library/de...y/en-us/cpguid
e/html/cpconemittingdynamicassemblies.asp
嗨Armin,
我的项目中有2种不同的表格:
frmTest
frmCompany
我可以申报使用代码的新表格:
dim frm as new frmTest
或
dim frm as new frmCompany
>
我想要的是当我有一个带有表单名称的字符串(strFormName)时我可以使用这个字符串来声明新的表单。
strEval =" Dim frm as new" &安培; strFormName
这样的东西。因此上面的字符串(strEval)将作为
代码行执行。
Hi Armin,
I have 2 different forms inside my project:
frmTest
frmCompany
I can declare a new form by using the code:
dim frm as new frmTest
OR
dim frm as new frmCompany
What I want is that when I have a string with the form name (strFormName) I
can use this string to declare the new form.
strEval = "Dim frm as new " & strFormName
Something like this. So the string above (strEval) will be executed as a
line of code.
" Maurice" ; < HM ***** @ nospam.nospam> schrieb
"Maurice" <hm*****@nospam.nospam> schrieb
嗨Armin,
我的项目中有两种不同的形式:
frmTest
frmCompany
我可以申报一个新的形式,使用代码:
昏暗的frm作为新的frmTest
或者昏暗的frm作为新的frmCompany
我想要的是,当我有一个字符串与表单名称
(strFormName)我可以使用此字符串来声明新表单。
strEval =" Dim frm as new" &安培; strFormName
这样的东西。所以上面的字符串(strEval)将作为一行代码执行
。
Hi Armin,
I have 2 different forms inside my project:
frmTest
frmCompany
I can declare a new form by using the code:
dim frm as new frmTest
OR
dim frm as new frmCompany
What I want is that when I have a string with the form name
(strFormName) I can use this string to declare the new form.
strEval = "Dim frm as new " & strFormName
Something like this. So the string above (strEval) will be executed
as a line of code.
连续三次要求按类名创建一个对象,'' s
为什么我指出前两个问题和答案。
为什么你的字符串中有类名?通常这不是必要的:
Dim frm as form
选择案例值
case这个
frm = new frmTest
case
frm = new frmCompany
end select
frm.show
Armin
Creating an object by class name has been asked three times in a row, that''s
why I pointed to the previous two questions and answers.
Why do you have the class name in a string? Often this is not necessary:
Dim frm as form
select case value
case This
frm = new frmTest
case That
frm = new frmCompany
end select
frm.show
Armin
这篇关于Eval函数vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!