从传递的表单中打开新表单作为参数vb.net

时间:2013-11-18 20:34:57

标签: vb.net winforms

是否可以打开sub传递的表单作为新表单,例如: vb.net 2010 windows窗体

Public Sub CheckMembership (byVal OpenFormName as form)

Using NewFormInstance as new OpenFormName
NewFormInstance.ShowDialog
End Using
End Sub

2 个答案:

答案 0 :(得分:1)

您无需创建传递给此方法的表单的新实例。你可以这样做:

Public Sub CheckMembership (byVal OpenFormName as form)
    OpenFormName.ShowDialog
End Sub

如果您想每次都打开一个新表单,您的方法中不需要参数。你可以这样做:

Public Sub CheckMembership()
    Dim OpenFormName As New YourFormClass
    OpenFormName.ShowDialog()
End Sub

答案 1 :(得分:0)

Public Sub CheckMembership (byval OpenFormName as form)

    OpenFormName.ShowDialog

End Sub