當我試圖調用此構造函數時出現錯誤Constructor call is valid only as the first statement in an instance constructor
。我該如何糾正?「構造函數調用僅作爲第一條語句有效」錯誤,但它是第一條語句
我調用構造函數是這樣的:
Dim frmPull As Shipping.frmPullFromLocation
frmPull = Shipping.frmPullFromLocation.New(datPickListDate, datRequestDate, datShipDate, intList, intQuantity, intRequest, strAdditionalInfo, strJobNumber, strItemCode)
frmPull.ShowDialog()
。
Public Sub New(ByVal datPickListDate As Date, ByVal datRequestDate As Date, ByVal datShipDate As Date, ByVal intList As Integer, ByVal intQuantity As Integer, ByVal intRequest As Integer, ByVal strAdditionalInfo As String, ByVal strJobNumber As String, ByVal strItemCode As String)
MyBase.New()
'Set local variables to the parameters passed in.
Me.datPickListDate = datPickListDate
Me.datRequestDate = datRequestDate
Me.datShipDate = datShipDate
Me.intList = intList
Me.intQuantity = intQuantity
Me.intRequest = intRequest
Me.strAdditionalInfo = strAdditionalInfo
Me.strJobNumber = strJobNumber
Me.strItemCode = strItemCode
Dim _frmPullFromLocation As frmPullFromLocation = Me
AddHandler MyBase.Load, New EventHandler(AddressOf _frmPullFromLocation.frmPullFromLocation_Load)
Me.blnShowMessage = True
Me.InitializeComponent()
End Sub
接下來的問題將會是你刪除/忽略了''在InitializeComponent()調用後添加任何初始化.'設計器生成的註釋 – Plutonix 2014-11-04 17:58:16
@Plutonix - 看到構建和運行正常...你能詳細說明嗎? – MAW74656 2014-11-04 18:02:38
@Pututix - 它們是vars,但是你建議在Me.InitializeComponent()調用之後進行初始化嗎? – MAW74656 2014-11-04 18:10:20