2014-04-23 58 views
-1

我收到错误消息“结构无法被索引,因为它没有默认属性”。任何人都可以告诉我我做错了什么?结构无法被索引,因为它没有默认属性

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

您声明myArray的类型FixedLengthString而不是作为FixedLengthString数组:

Public Structure ExampleStructure2 
    <VBFixedArray(7)> Public myArray As Length8FixedString() 
End Structure 

不知道这是否是你想要的,因为这暴露了更多的问题。如果这不是答案,那么你想要达成什么的解释将会有所帮助。

相关问题