方法 '<methodname1>' 必須宣告為 'Private',才能實作部分方法 '<methodname2>'

更新:2007 年 11 月

部分方法的實作必須宣告為 Private。例如,下列程式碼會造成此錯誤。

Partial Class Product

    ' Declaration of the partial method.
    Partial Private Sub valueChanged()
    End Sub

End Class
Partial Class Product

    ' Implementation of the partial method, with Private missing, 
    ' causes this error. 
    'Sub valueChanged()
    '    MsgBox(Value was changed to " & Me.Quantity)
    'End Sub

End Class

錯誤 ID:BC31441

若要更正這個錯誤

  • 在部分方法的實作中使用存取修飾詞 Private,如下列範例所示。

    Private Sub valueChanged()
        MsgBox(Value was changed to " & Me.Quantity)
    End Sub
    

請參閱

概念

部分方法

Visual Basic 中的存取層級