:属性'Item'为'ReadOnly':

 收藏
Public prvMainForm = VB6Form    
If prvMainForm IsNot Nothing Then
    CObj(prvMainForm).StatusBar.Panels(1) = "Initializing Folders..."
End If

我的代码很长,所以我刚刚在发生错误的地方添加了这个if循环。

该错误在If语句中可见。

属性“项目”为“只读”
回复
  • 不在服务区 回复

    StatusBar.Panels(1) returns a MSComctlLib.Panel.

    StatusBar.Panels(1) = "Initializing Folders..." is valid in VB6 because of default properties.

    Default properties in VB.NET must have parameters. A parameterless property cannot be default and therefore cannot be omitted. Thus, .Panels(1) = "..." is understood by VB.NET as an attempt to replace the entire Panel in the Panels property, which is not allowed.

    You can look up the name of the default property in the VB6 object browser, which turns out to be Property _ObjectDefault As String, so you should be able to do

    CObj(prvMainForm).StatusBar.Panels(1).[_ObjectDefault] = "Initializing Folders..."
    

    As you have observed, assigning Text should do the same:

    CObj(prvMainForm).StatusBar.Panels(1).Text = "Initializing Folders..."