Am getting: “Structure cannot be indexed because it has no default property”. What am I doing wrong?
With grid.Rows(10).Cells
Dim note As New Note With {.ID = "Blah", _
.Date = "1/1/2011", _
.Message = "AAA", _
.Type = "ABC", _
.SubType = "DEF", _
.ReferenceKey = !SetRefNum.Value}
End With
And Note looks like:
Public Structure Note
Public Property ID As String
Public Property [Date] As Date
Public Property Message As String
Public Property Type As String
Public Property SubType As String
Public Property ReferenceKey As String
End Structure
The problem is with
!SetRefNum.Value. You use the!operator to reference an index in a collection, usually a dictionary. TheNoteclass requires aDefaultproperty to use this terminology.So the term
!SetRefNum.Valuewill translate tonote.Item("SetRefNum.Value").I’m going to take a guess you’re after something completely different.
See the Member Access Operators section of the page Special Characters in Code (Visual Basic) for more information.
Edit: Ammended answer for ammended question.
I suggest the following approach:
Somehow, I doubt that will work either. You might need something like: