如果 Form 对象是使用参数创建的,为什么在填写 Form 值时会出错?
错误是:
对非共享成员的引用需要对象引用。
文件 ParentForm.vb
Public Class Maincls
Dim oChildForm as New ChildForm("abc") ' Causes an error, but removing the arguments removes the error
Dim oChildForm as New ChildForm ' Does not throw an error
Public Sub btnok_click
ChildForm.tbXYZ.Text = "abc" ' Reference to non-shared member needs an object reference
End Sub
End Class
文件 ChildForm.vb
Public Class ChildForm
Public Sub New(tempString as String)
InitializeComponent()
End Sub
End Class