引用“表格”来自模块的对象 [英] Referencing "Forms" objects from a module

查看:76
本文介绍了引用“表格”来自模块的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,


(这里很简单)...


这可能是一个愚蠢的问题 - 请裸露和我一起,因为我是新来的

dotNet。


如何从模块中引用表单上的对象?在6.0中你可以

只需提供表单名称作为表单中对象的前缀,并且

就可以做到(有点像提供一个完全限定的路径名​​)一个

文件)。


从VB.net模块获取此类引用的机制是什么?


提前感谢您的任何见解


-Paul

All,

(here''s an easy one)...

This is probably a stupid question - please bare with me as I am new to
dotNet.

How does one reference objects on a form from a module? In 6.0 you could
simply provide the form name as a prefix to the object within the form and
that would do it (kind of like providing a fully qualified path name to a
file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight

-Paul

推荐答案

您可以轻松找到答案,在以下代码


------------------------------------ ------------------------------------


模块模块1


函数A_Function()

MessageBox.Show(&im; module1")

结束函数


结束模块


----------------------------- -------------------------------------------

Public Class Form1

继承System.Windows.Forms.Form


Private Sub Form1_Load(ByVal sender As System.Object,ByVal e作为

System.EventArgs)处理MyBase.Load

Module1.A_Function()


结束子

结束班

-------------------------------------- ----------------------------------

your can easily find answer, in the following code

------------------------------------------------------------------------

Module Module1

Function A_Function()
MessageBox.Show(" i m in module1")
End Function

End Module

------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Module1.A_Function()

End Sub
End Class
------------------------------------------------------------------------


差不多。


您提供的代码片段显示相反的情况。


您正在从表单中引用模块函数。我想从模块中引用一个表单

对象。我已经尝试了我在

原始帖子中描述的6.0语法 - 它与form-to-module几乎相同。参考

您已经说明了。


如何从模块中引用表单对象?

" Debugger81" <所以********** @ gmail.com>在消息中写道

news:11 ********************** @ g49g2000cwa.googlegr oups.com ...
Almost.

The code snipit you provided shows the reverse.

You are referncing a module function from a form. I want to reference a form
object from a module. I have tried the 6.0 syntax which I described in my
original post - it''s pretty much the same as the "form-to-module" reference
that you have illustrated.

How does one reference a form object from within a module?
"Debugger81" <so**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
您可以轻松找到答案,在以下代码中

---------------------------- --------------------------------------------

功能A_Function()
MessageBox.Show(&im; in module1")
结束功能

结束模块
--------------------------------------------- ---------------------------

公共类Form1
继承System.Windows.Forms.Form

Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Load
Module1.A_Function()
End Sub
End Class
------------------------------------- -----------------------------------
your can easily find answer, in the following code

------------------------------------------------------------------------

Module Module1

Function A_Function()
MessageBox.Show(" i m in module1")
End Function

End Module

------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Module1.A_Function()

End Sub
End Class
------------------------------------------------------------------------


" Paul Helmuth" < pH值****** @ cvit.com> schrieb
"Paul Helmuth" <ph******@cvit.com> schrieb
全部,

(这里很简单)...

这可能是一个愚蠢的问题 - 请光临我因为我是dotNet的新手。

如何从模块中引用表单上的对象?在6.0中,您可以简单地将表单名称作为表单中的对象的前缀提供,并且可以这样做(有点像为文件提供完全
限定的路径名​​)。

来自VB.net模块的这种引用的机制是什么?

提前感谢任何见解
All,

(here''s an easy one)...

This is probably a stupid question - please bare with me as I am new
to dotNet.

How does one reference objects on a form from a module? In 6.0 you
could simply provide the form name as a prefix to the object within
the form and that would do it (kind of like providing a fully
qualified path name to a file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight



如果可能,不要使用模块。请参阅此组中之前的讨论。


为什么不将代码放在表格中?

Armin


If possible, don''t use a Module. See previous discussions in this group.

Why don''t you put the code in the Form?
Armin


这篇关于引用“表格”来自模块的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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