简体   繁体   中英

Structure cannot be indexed because it has no default property

I am getting the error message "Structure cannot be indexed because it has no default property". can anyone please show me what I'm doing wrong?

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

You declared myArray as type FixedLengthString instead of as an array of FixedLengthString:

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

Not sure if this is what you want because this exposes more problems. An explanation of what you're trying to achieve will help if this isn't the answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM