我收到错误消息“结构无法编入索引,因为它没有默认属性”。谁能告诉我我做错了什么?
Public Structure Length8FixedString
<VBFixedString(8)> Public myFixedString As String '8 is the STRING length.
End Structure
Public Structure ExampleStructure2
<VBFixedArray(7)> Public myArray As Length8FixedString
End Structure
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim V As New ExampleStructure2
V.myArray(1) = "TIM" 'ERROR: Structure cannot be indexed because it has no default property
End Sub
End Class
答案 0 :(得分:0)
您将myArray声明为FixedLengthString类型而不是FixedLengthString数组:
Public Structure ExampleStructure2
<VBFixedArray(7)> Public myArray As Length8FixedString()
End Structure
不确定这是否是您想要的,因为这会暴露更多问题。如果不是答案,那么对你想要达到的目标的解释会有所帮助。