What am I doing wrong: Structure cannot be indexed because it has no default property (WITH CLAUSE)

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. The Note class requires a Default property to use this terminology.

Class Note
    Public ReadOnly Default Property Item(Key As String) As String
            Return Settings(Key)
        End Get
    End Property
    Private Settings As New Dictionary(Of String, String)
End Class

So the term !SetRefNum.Value will translate to note.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:

With grid.Rows(10).Cells
    Dim ReferenceKey As String = !SetRefNum.Value
    Dim note As New Note With {.ID = "Blah", _
                               .Date = "1/1/2011", _
                               .Message = "AAA", _
                               .Type = "ABC", _
                               .SubType = "DEF", _
                               .ReferenceKey = ReferenceKey}
End With

Somehow, I doubt that will work either. You might need something like:

With grid.Rows(10).Cells
    Dim ReferenceKey As String = .Item(SetRefNum.Value)

Need Your Help

rails connector for ckfinder or corefive.com/projects/filemanager

ruby-on-rails ruby ckeditor ckfinder file-manager

Is there any connector available for rails to use either ckfinder or corefive.com/projects/filemanager.

Does using tcp guarantee it will be sent/received?

delphi tcp winsock

I've been working on a simple winsock file transfer for a friend and me to share files without needing to upload to mediafire everytime.But a problem I have ran into is/was(depending on how you see...