形式的后期绑定??? [英] Late binding of forms???

查看:47
本文介绍了形式的后期绑定???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




在VB6中,我有以下代码...


Dim frmLink As Form

设置frmLink = Forms.Add(stringformname)

frmLink.Show

''等到所有数据都已加载

Do until frmLink。已加载= 21

DoEvent

循环

frmLink.Loaded = 31

调用frmLink.ExecuteLinked(strparameter)


stingformname和strparameter作为参数传递给函数。

我理解这段代码可能会引起麻烦:1)当表格带有

name stringformname不存在或者2)如果这个表单存在,但是没有
包含一个公共方法ExecuteLinked。我可以用

错误处理来理解它。


我想将此代码转换为VB.NET,但我在DESIGN TIME时遇到错误,

因为VB.NET不知道将使用哪种形式,因此不会将
识别为exebinLinked作为frmLink的公共函数。


我已经阅读了一些有关此问题的内容,但我找不到找到

的解决方法。任何想法都非常感激。


谢谢,

问候,

Peter Van wilrijk。

Hi,

In VB6 I have the following code ...

Dim frmLink As Form
Set frmLink = Forms.Add(stringformname)
frmLink.Show
''wait until all data has been loaded
Do Until frmLink.Loaded = 21
DoEvent
Loop
frmLink.Loaded = 31
Call frmLink.ExecuteLinked(strparameter)

stingformname and strparameter are passed as parameters to the function.
I understand this code might cause trouble : 1) when the form with
name stringformname doesn''t exist or 2) if this form exists, but doesn''t
contain a public method ExecuteLinked. I can catch it with
errorhandling of course.

I want to convert this code to VB.NET, but I get errors at DESIGN TIME,
because VB.NET doesn''t know which form will be used and so doesn''t
recognize the methode ExecuteLinked as a public function of frmLink.

I''ve read some things about this issue but I do not manage to find a
workaround. Any idea really appreciated.

Thanks,
Regards,
Peter Van wilrijk.

推荐答案

嗨Peter,


您可以使用特定的表单类型声明表单变量并转换为

it :


Dim frmLink As MyFormWithCustomMethods

设置frmLink = DirectCast(Forms.Add(stringformname),

MyFormWithCustomMethods)

frmLink.Show

''等到所有数据都已加载

Do until frmLink.Loaded = 21

DoEvent

循环

frmLink.Loaded = 31

调用frmLink.ExecuteLinked(strparameter)

-


祝你好运,


Carlos J. Quintero


MZ-Tools:Visual Studio的生产力加载项.NET,VB6,VB5和VBA

您可以更快地编写代码,设计和记录。

加载项开发人员的免费资源:
http://www.mztools.com

" Peter Van Wilrijk" < pr*@koopjeskrant.be> escribióenel mensaje

news:Vq ******************** @ phobos.telenet-ops.be ...
Hi Peter,

You can declare the form variable with the specific form type and cast to
it:

Dim frmLink As MyFormWithCustomMethods
Set frmLink = DirectCast(Forms.Add(stringformname),
MyFormWithCustomMethods)
frmLink.Show
''wait until all data has been loaded
Do Until frmLink.Loaded = 21
DoEvent
Loop
frmLink.Loaded = 31
Call frmLink.ExecuteLinked(strparameter)
--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"Peter Van Wilrijk" <pr*@koopjeskrant.be> escribió en el mensaje
news:Vq********************@phobos.telenet-ops.be...


在VB6中我有以下代码......

Dim frmLink As Form
设置frmLink = Forms.Add(stringformname)
frmLink.Show
''等到所有数据都已加载
Do frmLink.Loaded = 21
DoEvent
循环
frmLink.Loaded = 31
调用frmLink.ExecuteLinked(strparameter)

stingformname和strparameter作为参数传递给函数。我理解这段代码可能会造成麻烦:1)当名称
stringformname的表单不存在或2)如果这个表单存在,但不包含公共方法ExecuteLinked。我当然可以通过错误处理来理解它。

我想将此代码转换为VB.NET,但我在DESIGN TIME遇到错误,
因为VB.NET没有不知道将使用哪种形式,因此不会将方法ExecuteLinked识别为frmLink的公共功能。

我已经阅读了有关此问题的一些内容但我做了无法找到一个解决方法。任何想法真的很感激。

谢谢,
问候,
Peter Van wilrijk。
Hi,

In VB6 I have the following code ...

Dim frmLink As Form
Set frmLink = Forms.Add(stringformname)
frmLink.Show
''wait until all data has been loaded
Do Until frmLink.Loaded = 21
DoEvent
Loop
frmLink.Loaded = 31
Call frmLink.ExecuteLinked(strparameter)

stingformname and strparameter are passed as parameters to the function. I
understand this code might cause trouble : 1) when the form with name
stringformname doesn''t exist or 2) if this form exists, but doesn''t
contain a public method ExecuteLinked. I can catch it with errorhandling
of course.

I want to convert this code to VB.NET, but I get errors at DESIGN TIME,
because VB.NET doesn''t know which form will be used and so doesn''t
recognize the methode ExecuteLinked as a public function of frmLink.

I''ve read some things about this issue but I do not manage to find a
workaround. Any idea really appreciated.

Thanks,
Regards,
Peter Van wilrijk.



Hi Carlos ,


对不起,我是.NET的新手。我可以从你的例子中得出结论

MyFormWithCustomMethods是一种模板形式,你在其中实现没有代码的公共方法,只用于制作方法

可以继承表格吗?


我已经用Form1中的代码和空公共测试了你的建议

方法Form2和Form3中的ExecuteLinked,但我在DirectCast指令中的表单下得到一个(设计时间

错误)行,就好像系统

无法识别表格集。我使用框架1.0,

或许我要升级?


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理Button1.Click

Dim frmLink As Form2

Dim strFormName As String

strFormName =" Form3

frmLink = DirectCast(forms.add(strFormName),Form2)

frmLink.Show()

调用frmLink.ExecuteLinked()

结束子

非常感谢。

彼得。


Carlos J. Quintero [VB MVP]写道:
Hi Carlos,

Sorry, I''m rather new in .NET. May I conclude from your example that
MyFormWithCustomMethods is a kind of template form in which you
implement the public method without code, only used to make the method
available to inheriting forms??

I''ve tested you''re suggestion with this code in Form1 and a empty public
method ExecuteLinked in both Form2 and Form3, but I get a (design time
error) line under forms in the DirectCast instruction, as if the system
doesn''t recognize the forms collection. I work with framework 1.0,
perhaps I''ve to upgrade?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim frmLink As Form2
Dim strFormName As String
strFormName = "Form3"
frmLink = DirectCast(forms.add(strFormName), Form2)
frmLink.Show()
Call frmLink.ExecuteLinked()
End Sub
Thanks a lot.
Peter.

Carlos J. Quintero [VB MVP] wrote:
嗨Peter,

您可以使用特定的表单类型声明表单变量并转换为
它:

> Dim frmLink As MyFormWithCustomMethods
设置frmLink = DirectCast(Forms.Add(stringformname),
MyFormWithCustomMethods)
frmLink.Show
''等到所有数据都已加载
Do to frmLink.Loaded = 21
DoEvent
循环
frmLink.Loaded = 31
调用frmLink.ExecuteLinked(strparameter)
Hi Peter,

You can declare the form variable with the specific form type and cast to
it:

Dim frmLink As MyFormWithCustomMethods
Set frmLink = DirectCast(Forms.Add(stringformname),
MyFormWithCustomMethods)
frmLink.Show
''wait until all data has been loaded
Do Until frmLink.Loaded = 21
DoEvent
Loop
frmLink.Loaded = 31
Call frmLink.ExecuteLinked(strparameter)



Peter,

定义一个接口,然后各自表单实现界面。

然后将转换表单转换为接口类型并使用接口方法。


jeff


Peter Van Wilrijk < pr*@koopjeskrant.be>在消息中写道

新闻:Vq ******************** @ phobos.telenet-ops.be ...
Peter,
define an interface, then have each form implement the interface.
then cast cast form to the interface type and use the interface methods.

jeff

"Peter Van Wilrijk" <pr*@koopjeskrant.be> wrote in message
news:Vq********************@phobos.telenet-ops.be...


在VB6中我有以下代码......

Dim frmLink As Form
设置frmLink = Forms.Add(stringformname)
frmLink.Show
''等到所有数据都已加载
直到frmLink.Loaded = 21
DoEvent
循环
frmLink.Loaded = 31
stingformname和strparameter作为参数传递给函数。我理解这段代码可能会造成麻烦:1)当名称
stringformname的表单不存在或2)如果这个表单存在,但不包含公共方法ExecuteLinked。我当然可以通过错误处理来理解它。

我想将此代码转换为VB.NET,但我在DESIGN TIME遇到错误,
因为VB.NET没有不知道将使用哪种形式,因此不会将方法ExecuteLinked识别为frmLink的公共功能。

我已经阅读了有关此问题的一些内容但我做了无法找到一个解决方法。任何想法真的很感激。

谢谢,
问候,
Peter Van wilrijk。
Hi,

In VB6 I have the following code ...

Dim frmLink As Form
Set frmLink = Forms.Add(stringformname)
frmLink.Show
''wait until all data has been loaded
Do Until frmLink.Loaded = 21
DoEvent
Loop
frmLink.Loaded = 31
Call frmLink.ExecuteLinked(strparameter)

stingformname and strparameter are passed as parameters to the function. I
understand this code might cause trouble : 1) when the form with name
stringformname doesn''t exist or 2) if this form exists, but doesn''t
contain a public method ExecuteLinked. I can catch it with errorhandling
of course.

I want to convert this code to VB.NET, but I get errors at DESIGN TIME,
because VB.NET doesn''t know which form will be used and so doesn''t
recognize the methode ExecuteLinked as a public function of frmLink.

I''ve read some things about this issue but I do not manage to find a
workaround. Any idea really appreciated.

Thanks,
Regards,
Peter Van wilrijk.



这篇关于形式的后期绑定???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆