vb.net 怎么传递类参数
vb.net 如何传递类参数?如题,现有程序如下:Public Class 预处理Private Sub Form_Load(ByVal sender As S
vb.net 如何传递类参数?
'如题,现有程序如下:
Public Class 预处理
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
formInit(me)
end sub
Public Sub PictureBoxClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
end sub
end class
Module session
Public Sub formInit(ByRef formName As Object, ByVal STOP_PICTURE As String)
For Each pic In formName.Controls.OfType(Of PictureBox)()
Dim picture As PictureBox
picture = pic
AddHandler picture.Click, AddressOf formName.PictureBoxClick
Next
end sub
end module
'要实现的功能是:在“预处理”类中调用session里的函数,将预处理这个类传递过去,现在会报错:
'未找到类型“ControlCollection”的公共成员“OfType”。
'现在程序并不认为fromName是一个class,如何定义一个class类弄变量接接传递过来的“预处理”?
[解决办法]你预处理类不是继承窗体吗?
'如题,现有程序如下:
Public Class 预处理
inherits Form Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
formInit(me)
end sub
Public Sub PictureBoxClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
end sub
end class
Module session
Public Sub formInit(ByRef formName As
Form, ByVal STOP_PICTURE As String)
For Each pic In formName.Controls
if(pic.GetType().Name="PictureBox") then
Dim picture As PictureBox
picture = pic
AddHandler picture.Click, AddressOf formName.PictureBoxClick
end if Next
end sub
end module
'要实现的功能是:在“预处理”类中调用session里的函数,将预处理这个类传递过去,现在会报错:
'未找到类型“ControlCollection”的公共成员“OfType”。
'现在程序并不认为fromName是一个class,如何定义一个class类弄变量接接传递过来的“预处理”?