Vb.net &引用;构造函数调用仅在第一条语句“0”时有效;错误,但这是第一条语句

Vb.net &引用;构造函数调用仅在第一条语句“0”时有效;错误,但这是第一条语句,vb.net,oop,Vb.net,Oop,Getting error构造函数调用仅在我尝试调用此构造函数时作为实例构造函数中的第一条语句时有效。我怎样才能改正 我这样调用构造函数: Dim frmPull As Shipping.frmPullFromLocation frmPull = Shipping.frmPullFromLocation.New(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, i

Getting error
构造函数调用仅在我尝试调用此构造函数时作为实例构造函数中的第一条语句时有效。我怎样才能改正

我这样调用构造函数:

            Dim frmPull As Shipping.frmPullFromLocation
            frmPull = Shipping.frmPullFromLocation.New(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, intRequest, strAdditionalInfo, strJobNumber, strItemCode)
            frmPull.ShowDialog()

换成

        Dim frmPull As Shipping.frmPullFromLocation
        frmPull = new Shipping.frmPullFromLocation(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, intRequest, strAdditionalInfo, strJobNumber, strItemCode)
        '         ^^^ new!
        frmPull.ShowDialog()

您不能像调用共享或静态方法那样调用New。

下一个问题是您删除/忽略了在InitializeComponent()调用之后添加任何初始化。
设计器生成comment@Plutonix-似乎构建和运行正常。。。你能详细说明一下吗?@puropoix-它们是变量,但你是否建议在
Me.InitializeComponent()
call之后进行初始化是更好的做法?变量是可以的,但为了避免出现任何问题,我会在它之后进行所有设置。它可以防止您将一些
Me.TextBox…
引用到其他代码中,这样会破坏东西。表单是资源,应该进行处理。哦我当然知道这一点,但我一时忘了。多么尴尬。。。。
        Dim frmPull As Shipping.frmPullFromLocation
        frmPull = Shipping.frmPullFromLocation.New(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, intRequest, strAdditionalInfo, strJobNumber, strItemCode)
        frmPull.ShowDialog()
        Dim frmPull As Shipping.frmPullFromLocation
        frmPull = new Shipping.frmPullFromLocation(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, intRequest, strAdditionalInfo, strJobNumber, strItemCode)
        '         ^^^ new!
        frmPull.ShowDialog()